mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
1ecb41ebc0
133 changed files with 4571 additions and 1481 deletions
|
@ -58,6 +58,9 @@ public class AllManagedBuildTests {
|
|||
|
||||
TestSuite suite = new TestSuite("Test for org.eclipse.cdt.managedbuild.core.tests");
|
||||
//$JUnit-BEGIN$
|
||||
// Preconditions
|
||||
suite.addTestSuite(Preconditions.class);
|
||||
|
||||
// build.core.scannerconfig.tests
|
||||
suite.addTest(CfgScannerConfigProfileManagerTests.suite());
|
||||
suite.addTestSuite(GCCSpecsConsoleParserTest.class);
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012,2012 Andrew Gvozdev and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Gvozdev - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.tests.suite;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.utils.PathUtil;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||
|
||||
public class Preconditions extends TestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Many MBS tests run make and gcc and will inspect resulting artifacts of the build.
|
||||
* Make sure GNU tool-chain is available for the tests.
|
||||
*/
|
||||
public void testGnu() {
|
||||
IPath make = PathUtil.findProgramLocation("make");
|
||||
assertNotNull("Precodition FAILED - program 'make' is not found in path.", make);
|
||||
|
||||
IPath gcc = PathUtil.findProgramLocation("gcc");
|
||||
assertNotNull("Precodition FAILED - program 'gcc' is not found in path.", gcc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated makefiles will often contain dependency lines for all file extension
|
||||
* corresponding content types set in preferences. Make sure that this set has not been
|
||||
* changed when the tests are run.
|
||||
*/
|
||||
public void testContentTypes() {
|
||||
Set<String> fileExts = new TreeSet<String>();
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
|
||||
IContentType contentTypeCpp = manager.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
|
||||
fileExts.addAll(Arrays.asList(contentTypeCpp.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
|
||||
|
||||
IContentType contentTypeC = manager.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE);
|
||||
fileExts.addAll(Arrays.asList(contentTypeC.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
|
||||
|
||||
Set<String> expectedExts = new TreeSet<String>(Arrays.asList(new String[] {"C", "c", "c++", "cc", "cpp", "cxx"}));
|
||||
assertEquals("Precodition FAILED - Content Types do not match expected defaults.", expectedExts.toString(), fileExts.toString());
|
||||
}
|
||||
|
||||
}
|
|
@ -51,8 +51,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
|||
private static final String PROVIDER_ID = "provider.id";
|
||||
private static final String PROVIDER_NAME = "provider name";
|
||||
private static final String LANGUAGE_ID = "language.test.id";
|
||||
private static final String CUSTOM_PARAMETER = "customParameter";
|
||||
private static final String CUSTOM_PARAMETER_2 = "customParameter2";
|
||||
private static final String CUSTOM_COMMAND_1 = "echo 1";
|
||||
private static final String CUSTOM_COMMAND_2 = "echo 2";
|
||||
private static final String ELEM_TEST = "test";
|
||||
|
||||
// those attributes must match that in AbstractBuiltinSpecsDetector
|
||||
|
@ -203,7 +203,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
|||
List<String> languages = new ArrayList<String>();
|
||||
languages.add(LANGUAGE_ID);
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
properties.put(ATTR_PARAMETER, CUSTOM_PARAMETER);
|
||||
properties.put(ATTR_PARAMETER, CUSTOM_COMMAND_1);
|
||||
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
||||
ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
|
||||
entries.add(entry);
|
||||
|
@ -213,13 +213,13 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
|||
assertEquals(PROVIDER_NAME, provider.getName());
|
||||
assertEquals(languages, provider.getLanguageScope());
|
||||
assertEquals(entries, provider.getSettingEntries(null, null, null));
|
||||
assertEquals(CUSTOM_PARAMETER, provider.getCommand());
|
||||
assertEquals(CUSTOM_COMMAND_1, provider.getCommand());
|
||||
assertEquals(false, provider.isConsoleEnabled());
|
||||
assertEquals(false, provider.isExecuted());
|
||||
|
||||
// setters
|
||||
provider.setCommand(CUSTOM_PARAMETER_2);
|
||||
assertEquals(CUSTOM_PARAMETER_2, provider.getCommand());
|
||||
provider.setCommand(CUSTOM_COMMAND_2);
|
||||
assertEquals(CUSTOM_COMMAND_2, provider.getCommand());
|
||||
provider.setConsoleEnabled(true);
|
||||
assertEquals(true, provider.isConsoleEnabled());
|
||||
|
||||
|
@ -259,7 +259,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
|||
|
||||
// configure provider
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
properties.put(ATTR_PARAMETER, CUSTOM_PARAMETER);
|
||||
properties.put(ATTR_PARAMETER, CUSTOM_COMMAND_1);
|
||||
provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, languages, entries, properties);
|
||||
assertEquals(false, provider.isConsoleEnabled());
|
||||
provider.setConsoleEnabled(true);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model.tests;
|
||||
|
||||
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
|||
|
||||
/**
|
||||
* @author bnicolle
|
||||
*
|
||||
*/
|
||||
public class IStructureTests extends IntegratedCModelTest {
|
||||
/**
|
||||
|
@ -56,29 +55,29 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
* containing all its public members named "test*"
|
||||
*/
|
||||
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
|
||||
|
||||
// Interface tests:
|
||||
suite.addTest( new IStructureTests("testGetChildrenOfTypeStruct"));
|
||||
suite.addTest( new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
|
||||
suite.addTest( new IStructureTests("testGetFields"));
|
||||
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetFieldsHack"));
|
||||
suite.addTest( new IStructureTests("testGetField"));
|
||||
suite.addTest( new IStructureTests("testGetMethods")); // C++ only
|
||||
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetMethodsHack")); // C++ only
|
||||
suite.addTest( new IStructureTests("testGetMethod")); // C++ only
|
||||
suite.addTest( new IStructureTests("testIsStruct"));
|
||||
suite.addTest( new IStructureTests("testIsClass")); // C++ only
|
||||
suite.addTest( new IStructureTests("testIsUnion"));
|
||||
suite.addTest( new IStructureTests("testIsAbstract")); // C++ only
|
||||
suite.addTest( new IStructureTests("testGetBaseTypes")); // C++ only
|
||||
suite.addTest( new IStructureTests("testGetAccessControl")); // C++ only
|
||||
suite.addTest(new IStructureTests("testGetChildrenOfTypeStruct"));
|
||||
suite.addTest(new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
|
||||
suite.addTest(new IStructureTests("testGetFields"));
|
||||
//Bug# 38985: solved. suite.addTest(new IStructureTests("testGetFieldsHack"));
|
||||
suite.addTest(new IStructureTests("testGetField"));
|
||||
suite.addTest(new IStructureTests("testGetMethods")); // C++ only
|
||||
//Bug# 38985: solved. suite.addTest(new IStructureTests("testGetMethodsHack")); // C++ only
|
||||
suite.addTest(new IStructureTests("testGetMethod")); // C++ only
|
||||
suite.addTest(new IStructureTests("testIsStruct"));
|
||||
suite.addTest(new IStructureTests("testIsClass")); // C++ only
|
||||
suite.addTest(new IStructureTests("testIsUnion"));
|
||||
suite.addTest(new IStructureTests("testIsAbstract")); // C++ only
|
||||
suite.addTest(new IStructureTests("testGetBaseTypes")); // C++ only
|
||||
suite.addTest(new IStructureTests("testGetAccessControl")); // C++ only
|
||||
|
||||
// Language Specification tests:
|
||||
suite.addTest( new IStructureTests("testAnonymousStructObject"));
|
||||
suite.addTest( new IStructureTests("testInnerStruct"));
|
||||
suite.addTest(new IStructureTests("testAnonymousStructObject"));
|
||||
suite.addTest(new IStructureTests("testInnerStruct"));
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
@ -92,9 +91,9 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
"testStruct8"
|
||||
};
|
||||
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);
|
||||
assertNotNull( "Failed on "+i, myIStruct);
|
||||
assertNotNull("Failed on " + i, myIStruct);
|
||||
assertEquals(myExpectedStructs[i], myIStruct.getElementName());
|
||||
}
|
||||
}
|
||||
|
@ -103,11 +102,11 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
List arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS);
|
||||
String[] myExpectedClasses = {
|
||||
"testClass1", "testClass2NoSemicolon", "testClass3", "testClass4Abstract",
|
||||
"testClass5", "testClass6"};
|
||||
"testClass5", "testClass6" };
|
||||
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);
|
||||
assertNotNull( "Failed on "+i, myIStruct);
|
||||
assertNotNull("Failed on " + i, myIStruct);
|
||||
assertEquals(myExpectedClasses[i], myIStruct.getElementName());
|
||||
}
|
||||
}
|
||||
|
@ -122,9 +121,9 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
"m_field4","m_field5","m_field6",
|
||||
};
|
||||
assertEquals(myExpectedFields.length, myArrayIField.length);
|
||||
for(int i=0; i<myArrayIField.length; i++) {
|
||||
assertNotNull( "Failed on "+i, myArrayIField[i]);
|
||||
assertEquals("Failed on "+i,
|
||||
for (int i= 0; i < myArrayIField.length; i++) {
|
||||
assertNotNull("Failed on " + i, myArrayIField[i]);
|
||||
assertEquals("Failed on " + i,
|
||||
myExpectedFields[i], myArrayIField[i].getElementName());
|
||||
}
|
||||
}
|
||||
|
@ -140,10 +139,10 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
};
|
||||
List myArrayIField = myIStruct.getChildrenOfType(ICElement.C_FIELD);
|
||||
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);
|
||||
assertNotNull( "Failed on "+i, myIField );
|
||||
assertEquals("Failed on "+i,
|
||||
assertNotNull("Failed on " + i, myIField);
|
||||
assertEquals("Failed on " + i,
|
||||
myExpectedFields[i], myIField.getElementName());
|
||||
}
|
||||
}
|
||||
|
@ -155,17 +154,17 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
"m_field1","m_field2","m_field3",
|
||||
"m_field4","m_field5","m_field6",
|
||||
};
|
||||
for(int i=0; i<myExpectedFields.length; i++) {
|
||||
IField myIField = myIStruct.getField( myExpectedFields[i] );
|
||||
assertNotNull( "Failed on "+i, myIField);
|
||||
for (int i= 0; i < myExpectedFields.length; i++) {
|
||||
IField myIField = myIStruct.getField(myExpectedFields[i]);
|
||||
assertNotNull("Failed on " + i, myIField);
|
||||
}
|
||||
|
||||
String[] myUnexpectedFields = {
|
||||
"m_field7","m_field8","m_field9",
|
||||
};
|
||||
for(int i=0; i<myUnexpectedFields.length; i++) {
|
||||
IField myIField = myIStruct.getField( myUnexpectedFields[i] );
|
||||
assertNull( "Failed on "+i, myIField);
|
||||
for (int i= 0; i < myUnexpectedFields.length; i++) {
|
||||
IField myIField = myIStruct.getField(myUnexpectedFields[i]);
|
||||
assertNull("Failed on " + i, myIField);
|
||||
}
|
||||
}
|
||||
public void testGetMethods() throws CModelException {
|
||||
|
@ -177,9 +176,9 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
"method1","method2","testStruct1","~testStruct1"
|
||||
};
|
||||
assertEquals(myExpectedMethods.length, myArrayIMethod.length);
|
||||
for(int i=0; i<myArrayIMethod.length; i++) {
|
||||
assertNotNull( "Failed on "+i, myArrayIMethod[i]);
|
||||
assertEquals("Failed on "+i,
|
||||
for (int i= 0; i < myArrayIMethod.length; i++) {
|
||||
assertNotNull("Failed on " + i, myArrayIMethod[i]);
|
||||
assertEquals("Failed on " + i,
|
||||
myExpectedMethods[i], myArrayIMethod[i].getElementName());
|
||||
}
|
||||
}
|
||||
|
@ -189,15 +188,15 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
List myArrayIMethod = myIStruct.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
||||
myArrayIMethod.addAll( myIStruct.getChildrenOfType(ICElement.C_METHOD) );
|
||||
myArrayIMethod.addAll(myIStruct.getChildrenOfType(ICElement.C_METHOD));
|
||||
String[] myExpectedMethods = {
|
||||
"method1","method2","testStruct1","~testStruct1"
|
||||
};
|
||||
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);
|
||||
assertNotNull( "Failed on "+i, myIMethod);
|
||||
assertEquals("Failed on "+i,
|
||||
assertNotNull("Failed on " + i, myIMethod);
|
||||
assertEquals("Failed on " + i,
|
||||
myExpectedMethods[i], myIMethod.getElementName());
|
||||
}
|
||||
}
|
||||
|
@ -208,17 +207,17 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
String[] myExpectedMethods = {
|
||||
"method1","method2","testStruct1","~testStruct1"
|
||||
};
|
||||
for(int i=0; i<myExpectedMethods.length; i++) {
|
||||
IMethodDeclaration myIMethod = myIStruct.getMethod( myExpectedMethods[i] );
|
||||
assertNotNull( "Failed on "+i, myIMethod);
|
||||
for (int i= 0; i < myExpectedMethods.length; i++) {
|
||||
IMethodDeclaration myIMethod = myIStruct.getMethod(myExpectedMethods[i]);
|
||||
assertNotNull("Failed on " + i, myIMethod);
|
||||
}
|
||||
|
||||
String[] myUnexpectedMethods = {
|
||||
"method7","method8","method9",
|
||||
};
|
||||
for(int i=0; i<myUnexpectedMethods.length; i++) {
|
||||
IMethodDeclaration myIMethod = myIStruct.getMethod( myUnexpectedMethods[i] );
|
||||
assertNull( "Failed on "+i, myIMethod);
|
||||
for (int i= 0; i < myUnexpectedMethods.length; i++) {
|
||||
IMethodDeclaration myIMethod = myIStruct.getMethod(myUnexpectedMethods[i]);
|
||||
assertNull("Failed on " + i, myIMethod);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,23 +228,22 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
try {
|
||||
myElementUnion = tu.getElement("testUnion1");
|
||||
myElementNonUnion = tu.getElement("testStruct1");
|
||||
} catch (CModelException e) {
|
||||
assertNotNull("CModelException thrown", e);
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElementUnion );
|
||||
assertTrue( myElementUnion.getElementType()==ICElement.C_UNION );
|
||||
assertNotNull(myElementUnion);
|
||||
assertTrue(myElementUnion.getElementType() == ICElement.C_UNION);
|
||||
IStructure myStructUnion = (IStructure) myElementUnion;
|
||||
assertNotNull( myStructUnion );
|
||||
assertTrue( myStructUnion.isUnion() );
|
||||
assertNotNull(myStructUnion);
|
||||
assertTrue(myStructUnion.isUnion());
|
||||
|
||||
assertNotNull( myElementNonUnion );
|
||||
assertTrue( myElementNonUnion.getElementType()!=ICElement.C_UNION );
|
||||
assertNotNull(myElementNonUnion);
|
||||
assertTrue(myElementNonUnion.getElementType() != ICElement.C_UNION);
|
||||
IStructure myStructNonUnion = (IStructure) myElementNonUnion;
|
||||
assertNotNull( myStructNonUnion );
|
||||
assertFalse( myStructNonUnion.isUnion() );
|
||||
assertNotNull(myStructNonUnion);
|
||||
assertFalse(myStructNonUnion.isUnion());
|
||||
}
|
||||
|
||||
public void testIsStruct() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElementStruct = null;
|
||||
|
@ -253,22 +251,20 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
try {
|
||||
myElementStruct = tu.getElement("testStruct1");
|
||||
myElementNonStruct = tu.getElement("testClass1");
|
||||
} catch (CModelException e) {
|
||||
assertNotNull("CModelException thrown", e);
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElementStruct );
|
||||
assertTrue( myElementStruct.getElementType()==ICElement.C_STRUCT );
|
||||
assertNotNull(myElementStruct);
|
||||
assertTrue(myElementStruct.getElementType() == ICElement.C_STRUCT);
|
||||
IStructure myStructStruct = (IStructure) myElementStruct;
|
||||
assertNotNull( myStructStruct );
|
||||
assertTrue( myStructStruct.isStruct() );
|
||||
assertNotNull(myStructStruct);
|
||||
assertTrue(myStructStruct.isStruct());
|
||||
|
||||
assertNotNull( myElementNonStruct );
|
||||
assertTrue( myElementNonStruct.getElementType()!=ICElement.C_STRUCT );
|
||||
assertNotNull(myElementNonStruct);
|
||||
assertTrue(myElementNonStruct.getElementType() != ICElement.C_STRUCT);
|
||||
IStructure myStructNonStruct = (IStructure) myElementNonStruct;
|
||||
assertNotNull( myStructNonStruct );
|
||||
assertFalse( myStructNonStruct.isStruct() );
|
||||
assertNotNull(myStructNonStruct);
|
||||
assertFalse(myStructNonStruct.isStruct());
|
||||
}
|
||||
|
||||
public void testIsClass() throws CModelException {
|
||||
|
@ -278,22 +274,20 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
try {
|
||||
myElementClass = tu.getElement("testClass1");
|
||||
myElementNonClass = tu.getElement("testStruct1");
|
||||
} catch (CModelException e) {
|
||||
assertNotNull("CModelException thrown", e);
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElementClass );
|
||||
assertTrue( myElementClass.getElementType()==ICElement.C_CLASS );
|
||||
assertNotNull(myElementClass);
|
||||
assertTrue(myElementClass.getElementType() == ICElement.C_CLASS);
|
||||
IStructure myStructClass = (IStructure) myElementClass;
|
||||
assertNotNull( myStructClass );
|
||||
assertTrue( myStructClass.isClass() );
|
||||
assertNotNull(myStructClass);
|
||||
assertTrue(myStructClass.isClass());
|
||||
|
||||
assertNotNull( myElementNonClass );
|
||||
assertTrue( myElementNonClass.getElementType()!=ICElement.C_CLASS );
|
||||
assertNotNull(myElementNonClass);
|
||||
assertTrue(myElementNonClass.getElementType() != ICElement.C_CLASS);
|
||||
IStructure myStructNonClass = (IStructure) myElementNonClass;
|
||||
assertNotNull( myStructNonClass );
|
||||
assertFalse( myStructNonClass.isClass() );
|
||||
assertNotNull(myStructNonClass);
|
||||
assertFalse(myStructNonClass.isClass());
|
||||
}
|
||||
|
||||
public void testIsAbstract() throws CModelException {
|
||||
|
@ -303,22 +297,20 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
try {
|
||||
myElementAbstract = tu.getElement("testClass4Abstract");
|
||||
myElementNonAbstract = tu.getElement("testClass1");
|
||||
} catch (CModelException e) {
|
||||
assertNotNull("CModelException thrown", e);
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElementAbstract );
|
||||
assertTrue( myElementAbstract.getElementType()==ICElement.C_CLASS );
|
||||
assertNotNull(myElementAbstract);
|
||||
assertTrue(myElementAbstract.getElementType() == ICElement.C_CLASS);
|
||||
IStructure myStructAbstract = (IStructure) myElementAbstract;
|
||||
assertNotNull( myStructAbstract );
|
||||
assertTrue( myStructAbstract.isAbstract() );
|
||||
assertNotNull(myStructAbstract);
|
||||
assertTrue(myStructAbstract.isAbstract());
|
||||
|
||||
assertNotNull( myElementNonAbstract );
|
||||
assertTrue( myElementNonAbstract.getElementType() == ICElement.C_CLASS );
|
||||
assertNotNull(myElementNonAbstract);
|
||||
assertTrue(myElementNonAbstract.getElementType() == ICElement.C_CLASS);
|
||||
IStructure myStructNonAbstract = (IStructure) myElementNonAbstract;
|
||||
assertNotNull( myStructNonAbstract );
|
||||
assertFalse( myStructNonAbstract.isAbstract() );
|
||||
assertNotNull(myStructNonAbstract);
|
||||
assertFalse(myStructNonAbstract.isAbstract());
|
||||
}
|
||||
|
||||
// IInheritance
|
||||
|
@ -328,23 +320,21 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
String[] myBaseTypes = null;
|
||||
try {
|
||||
myElementDerived = tu.getElement("testClass5"); // throws
|
||||
assertNotNull( myElementDerived );
|
||||
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
||||
assertNotNull(myElementDerived);
|
||||
assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
|
||||
IStructure myStructDerived = (IStructure) myElementDerived;
|
||||
assertNotNull( myStructDerived );
|
||||
assertNotNull(myStructDerived);
|
||||
myBaseTypes = myStructDerived.getSuperClassesNames();
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
} catch (CModelException e) {
|
||||
assertNotNull("CModelException thrown", e);
|
||||
}
|
||||
|
||||
String[] myExpectedBaseTypes = {
|
||||
"testClass1","testClass3","testClass4Abstract"
|
||||
"testClass1", "testClass3","testClass4Abstract"
|
||||
};
|
||||
assertEquals( myExpectedBaseTypes.length, myBaseTypes.length );
|
||||
for(int i=0; i<myBaseTypes.length; i++) {
|
||||
assertEquals( "Failed on "+i, myExpectedBaseTypes[i], myBaseTypes[i] );
|
||||
assertEquals(myExpectedBaseTypes.length, myBaseTypes.length);
|
||||
for (int i= 0; i < myBaseTypes.length; i++) {
|
||||
assertEquals("Failed on " + i, myExpectedBaseTypes[i], myBaseTypes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,10 +345,10 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
String[] myBaseTypes = null;
|
||||
try {
|
||||
myElementDerived = tu.getElement("testClass5"); // throws
|
||||
assertNotNull( myElementDerived );
|
||||
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
||||
assertNotNull(myElementDerived);
|
||||
assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
|
||||
IStructure myStructDerived = (IStructure) myElementDerived;
|
||||
assertNotNull( myStructDerived );
|
||||
assertNotNull(myStructDerived);
|
||||
myBaseTypes = myStructDerived.getSuperClassesNames();
|
||||
|
||||
ASTAccessVisibility[] myExpectedAccessControl = {
|
||||
|
@ -367,15 +357,13 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
ASTAccessVisibility.PROTECTED,
|
||||
ASTAccessVisibility.PRIVATE
|
||||
};
|
||||
assertEquals( myExpectedAccessControl.length, myBaseTypes.length );
|
||||
for(int i=0; i<myBaseTypes.length; i++) {
|
||||
assertEquals(myExpectedAccessControl.length, myBaseTypes.length);
|
||||
for (int i= 0; i < myBaseTypes.length; i++) {
|
||||
ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]);
|
||||
assertEquals( "Failed on "+i, myExpectedAccessControl[i], myAccessControl );
|
||||
assertEquals("Failed on " + i, myExpectedAccessControl[i], myAccessControl);
|
||||
}
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
} catch (CModelException e) {
|
||||
assertNotNull("CModelException thrown", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,13 +387,11 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
ICElement myElement = null;
|
||||
try {
|
||||
myElement = tu.getElement("testAnonymousStructObject1");
|
||||
} catch (CModelException e) {
|
||||
assertNotNull("CModelException thrown", e);
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElement );
|
||||
assertEquals( ICElement.C_VARIABLE, myElement.getElementType() );
|
||||
assertNotNull(myElement);
|
||||
assertEquals(ICElement.C_VARIABLE, myElement.getElementType());
|
||||
}
|
||||
|
||||
public void testInnerStruct() throws CModelException {
|
||||
|
@ -413,24 +399,22 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
ICElement myElement = null;
|
||||
try {
|
||||
myElement = tu.getElement("testStruct8");
|
||||
} catch (CModelException e) {
|
||||
assertNotNull("CModelException thrown", e);
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElement );
|
||||
assertNotNull(myElement);
|
||||
IStructure myIStruct = (IStructure) myElement;
|
||||
assertNotNull( myIStruct );
|
||||
assertNotNull(myIStruct);
|
||||
|
||||
String[] myExpectedInnerStructs = {
|
||||
"testStruct9Inner", "testStruct10Inner"
|
||||
};
|
||||
List myInnerStructs = myIStruct.getChildrenOfType(ICElement.C_STRUCT);
|
||||
assertEquals( myExpectedInnerStructs.length, myInnerStructs.size() );
|
||||
for(int i=0; i<myExpectedInnerStructs.length; i++) {
|
||||
assertEquals(myExpectedInnerStructs.length, myInnerStructs.size());
|
||||
for (int i= 0; i < myExpectedInnerStructs.length; i++) {
|
||||
IStructure myInnerStruct = (IStructure) myInnerStructs.get(i);
|
||||
assertNotNull( "Failed on "+i, myInnerStruct );
|
||||
assertEquals( "Failed on "+i, myExpectedInnerStructs[i], myInnerStruct.getElementName() );
|
||||
assertNotNull("Failed on " + i, myInnerStruct);
|
||||
assertEquals("Failed on " + i, myExpectedInnerStructs[i], myInnerStruct.getElementName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
/*
|
||||
* Created on Jun 3, 2003
|
||||
* by bnicolle
|
||||
*/
|
||||
package org.eclipse.cdt.core.model.tests;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
|
@ -33,18 +29,13 @@ import org.eclipse.core.runtime.Path;
|
|||
|
||||
/**
|
||||
* @author bnicolle
|
||||
*
|
||||
*/
|
||||
public abstract class IntegratedCModelTest extends BaseTestCase {
|
||||
|
||||
private ICProject fCProject;
|
||||
private IFile sourceFile;
|
||||
private NullProgressMonitor monitor;
|
||||
private boolean structuralParse = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public IntegratedCModelTest() {
|
||||
super();
|
||||
}
|
||||
|
@ -113,5 +104,4 @@ public abstract class IntegratedCModelTest extends BaseTestCase {
|
|||
public void setStructuralParse(boolean structuralParse) {
|
||||
this.structuralParse = structuralParse;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -713,19 +713,20 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
|
||||
private IBinding binding(String section, int len) {
|
||||
IASTName name = findName(section, len);
|
||||
IASTName astName = findName(section, len);
|
||||
final String selection = section.substring(0, len);
|
||||
assertNotNull("Did not find \"" + selection + "\"", name);
|
||||
assertEquals(selection, name.getRawSignature());
|
||||
assertNotNull("No AST name for \"" + selection + "\"", astName);
|
||||
assertEquals(selection, astName.getRawSignature());
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||
IBinding binding = astName.resolveBinding();
|
||||
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
||||
|
||||
return name.resolveBinding();
|
||||
return astName.resolveBinding();
|
||||
}
|
||||
|
||||
private IBinding binding(String context, String name) {
|
||||
IASTName astName = findName(context, name);
|
||||
assertNotNull("No AST name for \"" + name + "\"", astName);
|
||||
assertEquals(name, astName.getRawSignature());
|
||||
|
||||
IBinding binding = astName.resolveBinding();
|
||||
|
|
|
@ -8436,13 +8436,20 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
|
||||
}
|
||||
|
||||
// auto x = x; // Self referring type.
|
||||
// auto x = y + z;
|
||||
// auto y = x;
|
||||
// auto z = x;
|
||||
// void test() {
|
||||
// for (auto a : a) {}
|
||||
// }
|
||||
public void testAutoType_305970() throws Exception {
|
||||
String code= getAboveComment();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
ICPPVariable x= bh.assertNonProblem("x =", 1);
|
||||
IProblemType pt= (IProblemType) x.getType();
|
||||
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
|
||||
BindingAssertionHelper bh = getAssertionHelper();
|
||||
ICPPVariable x= bh.assertNonProblem("x =", 1, ICPPVariable.class);
|
||||
IProblemType xt= (IProblemType) x.getType();
|
||||
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, xt.getID());
|
||||
ICPPVariable a= bh.assertNonProblem("a :", "a", ICPPVariable.class);
|
||||
IProblemType at= (IProblemType) a.getType();
|
||||
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, at.getID());
|
||||
}
|
||||
|
||||
// struct A { auto a = 1; }; // Auto-typed non-static fields are not allowed.
|
||||
|
@ -9951,4 +9958,19 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
public void testOrderInAmbiguityResolution_390759() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// namespace N {
|
||||
// enum E { A, B };
|
||||
// void bar(E);
|
||||
// }
|
||||
// struct S {
|
||||
// void operator()(N::E);
|
||||
// };
|
||||
// S bar;
|
||||
// int main() {
|
||||
// bar(N::A);
|
||||
// }
|
||||
public void testADLForFunctionObject_388287() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,12 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
return new BindingAssertionHelper(code, true);
|
||||
}
|
||||
|
||||
private CPPNameCollector getCPPNameCollector(IASTTranslationUnit ast) {
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
return collector;
|
||||
}
|
||||
|
||||
public void testBasicClassTemplate() throws Exception {
|
||||
IASTTranslationUnit tu = parse("template <class T> class A{ T t; };", CPP); //$NON-NLS-1$
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
|
@ -6211,23 +6217,25 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// myA.x = 42;
|
||||
// }
|
||||
public void testSimpleAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPClassType S = (ICPPClassType) collector.getName(0).resolveBinding();
|
||||
ICPPField x = (ICPPField) collector.getName(1).resolveBinding();
|
||||
ITypedef Alias = (ITypedef) collector.getName(2).resolveBinding();
|
||||
IFunction foo = (IFunction) collector.getName(4).resolveBinding();
|
||||
IVariable myA = (IVariable) collector.getName(6).resolveBinding();
|
||||
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
|
||||
ICPPField x = assertionHelper.assertNonProblem("int x", "x", ICPPField.class);
|
||||
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S", "Alias", ITypedef.class);
|
||||
IFunction foo = assertionHelper.assertNonProblem("void foo() {", "foo", IFunction.class);
|
||||
IVariable myA = assertionHelper.assertNonProblem("Alias myA", "myA", IVariable.class);
|
||||
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, x, 2);
|
||||
assertInstances(collector, Alias, 2);
|
||||
assertInstances(collector, foo, 1);
|
||||
assertInstances(collector, myA, 2);
|
||||
}
|
||||
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T x;
|
||||
|
@ -6238,15 +6246,17 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// myA.x = 42;
|
||||
// }
|
||||
public void testSpecifiedTemplateAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPClassType S = (ICPPClassType) collector.getName(1).resolveBinding();
|
||||
ICPPField x = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ITypedef Alias = (ITypedef) collector.getName(4).resolveBinding();
|
||||
IVariable myA = (IVariable) collector.getName(9).resolveBinding();
|
||||
ICPPSpecialization xRef = (ICPPSpecialization) collector.getName(11).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPClassType S = assertionHelper.assertNonProblem("struct S", "S", ICPPClassType.class);
|
||||
ICPPField x = assertionHelper.assertNonProblem("T x;", "x", ICPPField.class);
|
||||
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S<int>;", "Alias", ITypedef.class);
|
||||
IVariable myA = assertionHelper.assertNonProblem("Alias myA;", "myA", IVariable.class);
|
||||
ICPPSpecialization xRef = assertionHelper.assertNonProblem("myA.x = 42;", "x", ICPPSpecialization.class);
|
||||
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, Alias, 2);
|
||||
|
@ -6261,38 +6271,41 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// myA = 42;
|
||||
// }
|
||||
public void testTemplatedAliasBasicType() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPAliasTemplate Alias = (ICPPAliasTemplate) collector.getName(1).resolveBinding();
|
||||
ICPPAliasTemplateInstance AliasFloatInstance = (ICPPAliasTemplateInstance) collector.getName(3).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias", ICPPAliasTemplate.class);
|
||||
ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;", "Alias<float>", ICPPAliasTemplateInstance.class);
|
||||
|
||||
assertInstances(collector, Alias, 2);
|
||||
assertSameType(AliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0));
|
||||
assertSameType(aliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0));
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename T>
|
||||
// using TAlias = S<T>;
|
||||
// template<typename _T>
|
||||
// using TAlias = S<_T>;
|
||||
// void foo() {
|
||||
// TAlias<int> myA;
|
||||
// myA.t = 42;
|
||||
// }
|
||||
public void testTemplatedAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPClassType S = (ICPPClassType) collector.getName(1).resolveBinding();
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) collector.getName(4).resolveBinding();
|
||||
ICPPTemplateParameter TRef = (ICPPTemplateParameter) collector.getName(8).resolveBinding();
|
||||
ICPPAliasTemplate TAlias = (ICPPAliasTemplate) collector.getName(5).resolveBinding();
|
||||
ICPPVariable myA = (ICPPVariable) collector.getName(12).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(14).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPTemplateParameter T = assertionHelper.assertNonProblem("template<typename _T>", "_T", ICPPTemplateParameter.class);
|
||||
ICPPTemplateParameter TRef = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "_T", ICPPTemplateParameter.class);
|
||||
ICPPAliasTemplate TAlias = assertionHelper.assertNonProblem("using TAlias = S<_T>;", "TAlias", ICPPAliasTemplate.class);
|
||||
ICPPVariable myA = assertionHelper.assertNonProblem("TAlias<int> myA;", "myA", ICPPVariable.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = 42;", "t", ICPPSpecialization.class);
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, T, 2);
|
||||
|
@ -6319,26 +6332,26 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// myA.t3 = true;
|
||||
// }
|
||||
public void testTemplatedAliasDeclarationMultipleParameters() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField t1 = (ICPPField) collector.getName(5).resolveBinding();
|
||||
ICPPField t2 = (ICPPField) collector.getName(7).resolveBinding();
|
||||
ICPPField t3 = (ICPPField) collector.getName(9).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPField t1 = assertionHelper.assertNonProblem("T1 t1;", "t1", ICPPField.class);
|
||||
ICPPField t2 = assertionHelper.assertNonProblem("T2 t2;", "t2", ICPPField.class);
|
||||
ICPPField t3 = assertionHelper.assertNonProblem("T3 t3;", "t3", ICPPField.class);
|
||||
|
||||
ICPPTemplateParameter P1 = (ICPPTemplateParameter) collector.getName(10).resolveBinding();
|
||||
ICPPTemplateParameter P2 = (ICPPTemplateParameter) collector.getName(11).resolveBinding();
|
||||
ICPPTemplateParameter P1 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P1", ICPPTemplateParameter.class);
|
||||
ICPPTemplateParameter P2 = assertionHelper.assertNonProblem("template<typename P1, typename P2>", "P2", ICPPTemplateParameter.class);
|
||||
|
||||
ICPPTemplateParameter P1Ref = (ICPPTemplateParameter) collector.getName(16).resolveBinding();
|
||||
ICPPTemplateParameter P2Ref = (ICPPTemplateParameter) collector.getName(15).resolveBinding();
|
||||
ICPPTemplateParameter P1Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P1", ICPPTemplateParameter.class);
|
||||
ICPPTemplateParameter P2Ref = assertionHelper.assertNonProblem("using TAlias = S<int, P2, P1>;", "P2", ICPPTemplateParameter.class);
|
||||
|
||||
ICPPAliasTemplateInstance TAliasInstance = (ICPPAliasTemplateInstance) collector.getName(18).resolveBinding();
|
||||
ICPPAliasTemplateInstance TAliasInstance = assertionHelper.assertNonProblem("TAlias<bool, float> myA;", "TAlias<bool, float>", ICPPAliasTemplateInstance.class);
|
||||
ICPPTemplateInstance aliasedTypeInstance = (ICPPTemplateInstance) TAliasInstance.getType();
|
||||
|
||||
ICPPSpecialization t1Ref = (ICPPSpecialization) collector.getName(22).resolveBinding();
|
||||
ICPPSpecialization t2Ref = (ICPPSpecialization) collector.getName(24).resolveBinding();
|
||||
ICPPSpecialization t3Ref = (ICPPSpecialization) collector.getName(26).resolveBinding();
|
||||
ICPPSpecialization t1Ref = assertionHelper.assertNonProblem("myA.t1 = 42;", "t1", ICPPSpecialization.class);
|
||||
ICPPSpecialization t2Ref = assertionHelper.assertNonProblem("myA.t2 = 42.0f;", "t2", ICPPSpecialization.class);
|
||||
ICPPSpecialization t3Ref = assertionHelper.assertNonProblem("myA.t3 = true;", "t3", ICPPSpecialization.class);
|
||||
|
||||
assertEquals(P1, P1Ref);
|
||||
assertEquals(P2, P2Ref);
|
||||
|
@ -6358,17 +6371,17 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// template<typename P>
|
||||
// using TAlias = S<P>;
|
||||
// void foo() {
|
||||
// TAlias<S<int> > myA;
|
||||
// TAlias<S<int>> myA;
|
||||
// myA.t = S<int>();
|
||||
// }
|
||||
public void testTemplatedAliasDeclarationTemplateArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
IType TAliasSInt = (IType) collector.getName(10).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(16).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias<S<int>> myA;", "TAlias<S<int>>", ICPPAliasTemplateInstance.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>()", "t", ICPPSpecialization.class);
|
||||
|
||||
assertEquals(t, tRef.getSpecializedBinding());
|
||||
assertSameType(TAliasSInt, (IType)tRef.getOwner());
|
||||
|
@ -6381,17 +6394,17 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// template<typename P>
|
||||
// using TAlias = S<P>;
|
||||
// void foo() {
|
||||
// S<TAlias<int> > myA;
|
||||
// S<TAlias<int>> myA;
|
||||
// myA.t = S<int>();
|
||||
// }
|
||||
public void testTemplatedAliasAsTemplateArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPTemplateInstance STAliasInt = (ICPPTemplateInstance) collector.getName(10).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(16).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S<TAlias<int>> myA;", "S<TAlias<int>>", ICPPTemplateInstance.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
|
||||
|
||||
assertEquals(t, tRef.getSpecializedBinding());
|
||||
assertEquals(STAliasInt, tRef.getOwner());
|
||||
|
@ -6408,12 +6421,12 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// myA.buff[0] = 1;
|
||||
// }
|
||||
public void testTemplatedAliasDeclarationValueArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField buff = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPSpecialization buffRef = (ICPPSpecialization) collector.getName(17).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPField buff = assertionHelper.assertNonProblem("int buff [Size];", "buff", ICPPField.class);
|
||||
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
||||
|
||||
assertEquals(buff, buffRef.getSpecializedBinding());
|
||||
assertEquals(buffRef.getTemplateParameterMap().getArgument(0).getNonTypeValue().numericalValue(), new Long(4));
|
||||
|
@ -6431,13 +6444,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// myA.buff[0] = 1;
|
||||
// }
|
||||
public void testTemplatedAliasDefaultArguments() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField buff = (ICPPField) collector.getName(4).resolveBinding();
|
||||
ICPPAliasTemplateInstance myA = (ICPPAliasTemplateInstance) collector.getName(14).resolveBinding();
|
||||
ICPPSpecialization buffRef = (ICPPSpecialization) collector.getName(18).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPField buff = assertionHelper.assertNonProblem("T buff [Size];", "buff", ICPPField.class);
|
||||
ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>", ICPPAliasTemplateInstance.class);
|
||||
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
||||
|
||||
assertEquals(buff, buffRef.getSpecializedBinding());
|
||||
assertSameType(buffRef.getTemplateParameterMap().getArgument(0).getTypeValue(), new CPPBasicType(IBasicType.Kind.eInt, 0));
|
||||
|
@ -6455,14 +6468,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// myA.t = S<int>();
|
||||
// }
|
||||
public void testTemplatedAliasTemplateArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(17).resolveBinding();
|
||||
ICPPClassSpecialization Sint = (ICPPClassSpecialization) collector.getName(18).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem(" myA.t = S<int>();", "t", ICPPSpecialization.class);
|
||||
ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
|
||||
|
||||
assertEquals(t, tRef.getSpecializedBinding());
|
||||
assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint);
|
||||
|
@ -6483,14 +6495,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// bar(myS);
|
||||
// }
|
||||
public void testTemplatedAliasAsFunctionParameter() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ICPPFunction bar = (ICPPFunction) collector.getName(9).resolveBinding();
|
||||
ICPPFunction barRefAlias = (ICPPFunction) collector.getName(17).resolveBinding();
|
||||
ICPPFunction barRefSInt = (ICPPFunction) collector.getName(22).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(TAlias<int> arg){", "bar", ICPPFunction.class);
|
||||
ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
|
||||
ICPPFunction barRefSInt = assertionHelper.assertNonProblem("bar(myS);", "bar", ICPPFunction.class);
|
||||
|
||||
assertEquals(bar, barRefAlias);
|
||||
assertEquals(bar, barRefSInt);
|
||||
|
@ -6509,13 +6520,12 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// bar(myA);
|
||||
// }
|
||||
public void testTemplatedAliasAsFunctionArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPFunction bar = (ICPPFunction) collector.getName(9).resolveBinding();
|
||||
ICPPFunction barRefAlias = (ICPPFunction) collector.getName(17).resolveBinding();
|
||||
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(S<int> arg){", "bar", ICPPFunction.class);
|
||||
ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
|
||||
|
||||
assertEquals(bar, barRefAlias);
|
||||
}
|
||||
|
@ -6559,13 +6569,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// function f = &foo;
|
||||
// }
|
||||
public void testSimpleFunctionAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ITypedef function = (ITypedef) collector.getName(0).resolveBinding();
|
||||
ICPPFunction foo = (ICPPFunction) collector.getName(2).resolveBinding();
|
||||
ITypedef function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function", ITypedef.class);
|
||||
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int)", "foo", ICPPFunction.class);
|
||||
|
||||
assertInstances(collector, function, 2);
|
||||
assertInstances(collector, foo, 2);
|
||||
|
@ -6584,12 +6594,12 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// myA.t = 42;
|
||||
// }
|
||||
public void testTemplatedAliasForTemplateReference() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPClassSpecialization SInt = (ICPPClassSpecialization) collector.getName(10).resolveBinding();
|
||||
ICPPAliasTemplateInstance TAliasInt = (ICPPAliasTemplateInstance) collector.getName(13).resolveBinding();
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S<int> myS;", "S<int>", ICPPClassSpecialization.class);
|
||||
ICPPAliasTemplateInstance TAliasInt = assertionHelper.assertNonProblem("TAlias<int> myA = myS;", "TAlias<int>", ICPPAliasTemplateInstance.class);
|
||||
assertSameType(new CPPReferenceType(SInt, false), TAliasInt);
|
||||
|
||||
}
|
||||
|
@ -6600,14 +6610,14 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// function<int> f = &foo;
|
||||
// }
|
||||
public void testSimpleFunctionTemplateAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPAliasTemplate function = (ICPPAliasTemplate) collector.getName(1).resolveBinding();
|
||||
ICPPFunction foo = (ICPPFunction) collector.getName(3).resolveBinding();
|
||||
ICPPAliasTemplateInstance functionInt = (ICPPAliasTemplateInstance) collector.getName(5).resolveBinding();
|
||||
ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (int)", "function", ICPPAliasTemplate.class);
|
||||
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
|
||||
ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;", "function<int>", ICPPAliasTemplateInstance.class);
|
||||
|
||||
assertInstances(collector, function, 2);
|
||||
assertInstances(collector, foo, 2);
|
||||
|
@ -6620,14 +6630,14 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// function<int> f = &foo;
|
||||
// }
|
||||
public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPAliasTemplate function = (ICPPAliasTemplate) collector.getName(1).resolveBinding();
|
||||
ICPPFunction foo = (ICPPFunction) collector.getName(3).resolveBinding();
|
||||
ICPPAliasTemplateInstance functionInt = (ICPPAliasTemplateInstance) collector.getName(5).resolveBinding();
|
||||
ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function", ICPPAliasTemplate.class);
|
||||
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
|
||||
ICPPAliasTemplateInstance functionInt = assertionHelper.assertNonProblem("function<int> f = &foo;", "function<int>", ICPPAliasTemplateInstance.class);
|
||||
|
||||
assertInstances(collector, function, 2);
|
||||
assertInstances(collector, foo, 2);
|
||||
|
@ -6645,14 +6655,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// myA.t = S<int>();
|
||||
// }
|
||||
public void testTemplatedAliasTemplateParameter() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(17).resolveBinding();
|
||||
ICPPClassSpecialization Sint = (ICPPClassSpecialization) collector.getName(18).resolveBinding();
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
|
||||
ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
|
||||
|
||||
assertEquals(t, tRef.getSpecializedBinding());
|
||||
assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint);
|
||||
|
@ -6669,17 +6678,16 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// using namespace NS;
|
||||
// Alias<int> intAlias;
|
||||
public void testAliasDeclarationContext() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPAliasTemplateInstance AliasInt = (ICPPAliasTemplateInstance) collector.getName(11).resolveBinding();
|
||||
ICPPAliasTemplateInstance AliasInt = assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>", ICPPAliasTemplateInstance.class);
|
||||
assertEquals("Alias<int>", AliasInt.getName());
|
||||
assertEquals("NS", AliasInt.getQualifiedName()[0]);
|
||||
assertEquals("Alias<int>", AliasInt.getQualifiedName()[1]);
|
||||
|
||||
ICPPNamespace namespaceNS = (ICPPNamespace) collector.getName(0).resolveBinding();
|
||||
ICPPNamespace namespaceNS = assertionHelper.assertNonProblem("using namespace NS;", "NS", ICPPNamespace.class);
|
||||
assertEquals(namespaceNS, AliasInt.getOwner());
|
||||
|
||||
assertTrue(AliasInt.getScope() instanceof ICPPTemplateScope);
|
||||
|
@ -6726,7 +6734,165 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// void test(E<A<int>>::type v) {
|
||||
// f(v);
|
||||
// }
|
||||
public void testAliasTemplate_395026() throws Exception {
|
||||
public void testAliasTemplate_395026_1() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<typename U>
|
||||
// struct A {
|
||||
// template<typename V>
|
||||
// struct rebind {
|
||||
// typedef A<V> other;
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// template<typename T, typename U>
|
||||
// struct B {
|
||||
// typedef typename T::template rebind<U>::other type1;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct C {
|
||||
// template<typename U>
|
||||
// using rebind2 = typename B<T, U>::type1;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct D : C<T> {
|
||||
// typedef int* type0;
|
||||
// template<typename U>
|
||||
// struct rebind {
|
||||
// typedef typename C<T>::template rebind2<U> other;
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// template<typename U>
|
||||
// struct E {
|
||||
// typedef typename D<A<U>>::template rebind<U>::other type2;
|
||||
// typedef typename D<type2>::type0 type;
|
||||
// type operator[](int n);
|
||||
// };
|
||||
//
|
||||
// void f(int);
|
||||
//
|
||||
// void test() {
|
||||
// E<int*> v;
|
||||
// f(*v[0]);
|
||||
// }
|
||||
public void testAliasTemplate_395026_2() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<typename U>
|
||||
// struct A {
|
||||
// typedef U type1;
|
||||
//
|
||||
// template<typename V>
|
||||
// struct rebind {
|
||||
// typedef A<V> other;
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// template<typename T, typename U>
|
||||
// struct B {
|
||||
// template<typename T2, typename U2>
|
||||
// static constexpr bool test(typename T2::template rebind<U2>::other*) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// template<typename, typename>
|
||||
// static constexpr bool test(...) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// static const bool value = test<T, U>(nullptr);
|
||||
// };
|
||||
//
|
||||
// template<typename T, typename U, bool = B<T, U>::value>
|
||||
// struct C;
|
||||
//
|
||||
// template<typename T, typename U>
|
||||
// struct C<T, U, true> {
|
||||
// typedef typename T::template rebind<U>::other type2;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct D {
|
||||
// typedef typename T::type1 type3;
|
||||
//
|
||||
// template<typename U>
|
||||
// using rebind2 = typename C<T, U>::type2;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct E : D<T> {
|
||||
// typedef D<T> Base;
|
||||
// typedef typename Base::type3& type4;
|
||||
//
|
||||
// template<typename U>
|
||||
// struct rebind {
|
||||
// typedef typename Base::template rebind2<U> other;
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// template<typename U, typename T = A<U>>
|
||||
// struct F {
|
||||
// typedef typename E<T>::template rebind<U>::other type5;
|
||||
// typedef typename E<type5>::type4 type6;
|
||||
// type6 operator[](int n);
|
||||
// };
|
||||
//
|
||||
// void f(int);
|
||||
//
|
||||
// void test() {
|
||||
// F<int*> a;
|
||||
// f(*a[0]);
|
||||
// }
|
||||
public void testConstexprFunction_395238_1() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct A {
|
||||
// template<typename U>
|
||||
// static constexpr U test(U v) {
|
||||
// return v;
|
||||
// }
|
||||
//
|
||||
// template<typename>
|
||||
// static constexpr bool test(...) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// static const bool value = test<T>(true);
|
||||
// };
|
||||
//
|
||||
// template<typename T, bool = A<T>::value>
|
||||
// struct B;
|
||||
//
|
||||
// template<typename T>
|
||||
// struct B<T, true> {
|
||||
// typedef T type;
|
||||
// };
|
||||
//
|
||||
// B<bool>::type x;
|
||||
// B<int*>::type y;
|
||||
public void testConstexprFunction_395238_2() throws Exception {
|
||||
BindingAssertionHelper ah = getAssertionHelper();
|
||||
ITypedef td = ah.assertNonProblem("B<bool>::type", "type", ITypedef.class);
|
||||
assertEquals("bool", ASTTypeUtil.getType(td.getType()));
|
||||
ah.assertProblem("B<int*>::type", "type");
|
||||
}
|
||||
|
||||
// struct S {
|
||||
// typedef int a_type;
|
||||
// };
|
||||
// template <typename T, typename = typename T::a_type> int foo(T);
|
||||
// template <typename T, typename = typename T::b_type> void foo(T);
|
||||
// int main() {
|
||||
// foo(S());
|
||||
// }
|
||||
public void testSFINAEInDefaultArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,24 +165,31 @@ public class VariableReadWriteFlagsTest extends AST2BaseTest {
|
|||
// };
|
||||
//
|
||||
// void test(int a, int b, int c) {
|
||||
// A(&a, b);
|
||||
// A x(&a, b);
|
||||
// A(&a, b, c);
|
||||
// A y(&a, b, c);
|
||||
// A u = A(&a, b);
|
||||
// A* v = new A(&a, b);
|
||||
// A w(&a, b);
|
||||
// A x = A(&a, b, c);
|
||||
// A* y = new A(&a, b, c);
|
||||
// A z(&a, b, c);
|
||||
// };
|
||||
public void testConstructorCall_393068() throws Exception {
|
||||
AssertionHelper a = getCPPAssertionHelper();
|
||||
// a.assertReadWriteFlags("A(&a, b)", "a", READ | WRITE);
|
||||
// a.assertReadWriteFlags("A(&a, b)", "b", READ | WRITE);
|
||||
// a.assertReadWriteFlags("x(&a, b)", "a", READ | WRITE);
|
||||
// a.assertReadWriteFlags("x(&a, b)", "b", READ | WRITE);
|
||||
// a.assertReadWriteFlags("x(&a, b)", "x", WRITE);
|
||||
a.assertReadWriteFlags("A(&a, b, c)", "a", READ);
|
||||
a.assertReadWriteFlags("A(&a, b, c)", "b", READ);
|
||||
a.assertReadWriteFlags("A(&a, b, c)", "c", READ);
|
||||
a.assertReadWriteFlags("y(&a, b, c)", "a", READ);
|
||||
a.assertReadWriteFlags("y(&a, b, c)", "b", READ);
|
||||
a.assertReadWriteFlags("y(&a, b, c)", "c", READ);
|
||||
a.assertReadWriteFlags("= A(&a, b)", "a", READ | WRITE);
|
||||
a.assertReadWriteFlags("= A(&a, b)", "b", READ | WRITE);
|
||||
a.assertReadWriteFlags("new A(&a, b)", "a", READ | WRITE);
|
||||
a.assertReadWriteFlags("new A(&a, b)", "b", READ | WRITE);
|
||||
a.assertReadWriteFlags("w(&a, b)", "a", READ | WRITE);
|
||||
a.assertReadWriteFlags("w(&a, b)", "b", READ | WRITE);
|
||||
a.assertReadWriteFlags("w(&a, b)", "w", WRITE);
|
||||
a.assertReadWriteFlags("= A(&a, b, c)", "a", READ);
|
||||
a.assertReadWriteFlags("= A(&a, b, c)", "b", READ);
|
||||
a.assertReadWriteFlags("= A(&a, b, c)", "c", READ);
|
||||
a.assertReadWriteFlags("new A(&a, b, c)", "a", READ);
|
||||
a.assertReadWriteFlags("new A(&a, b, c)", "b", READ);
|
||||
a.assertReadWriteFlags("new A(&a, b, c)", "c", READ);
|
||||
a.assertReadWriteFlags("z(&a, b, c)", "a", READ);
|
||||
a.assertReadWriteFlags("z(&a, b, c)", "b", READ);
|
||||
a.assertReadWriteFlags("z(&a, b, c)", "c", READ);
|
||||
}
|
||||
|
||||
// struct A {
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public static class ProjectWithDepProj extends IndexCPPTemplateResolutionTest {
|
||||
public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));}
|
||||
public static TestSuite suite() {return suite(ProjectWithDepProj.class);}
|
||||
|
||||
|
||||
@Override
|
||||
public void testDefaultTemplateArgInHeader_264988() throws Exception {
|
||||
// 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(ProjectWithDepProj.suite());
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
IBinding b0= getBindingFromASTName("C1<char> c1", 8);
|
||||
IBinding b1= getBindingFromASTName("m1(\"aaa\")", 2);
|
||||
IBinding b2= getBindingFromASTName("m2(\"aaa\")", 2);
|
||||
|
||||
|
||||
assertEquals(1, getIndex().findNames(b1, 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 {
|
||||
IBinding b0= getBindingFromASTName("m1(\"aaa\")", 2);
|
||||
IBinding b1= getBindingFromASTName("m2(\"aaa\")", 2);
|
||||
|
||||
|
||||
assertEquals(1, getIndex().findNames(b0, 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 {
|
||||
IBinding b0= getBindingFromASTName("D<int> *var", 1);
|
||||
IBinding b1= getBindingFromASTName("D<int> *var", 6);
|
||||
|
||||
|
||||
assertInstance(b0, ICPPClassTemplate.class);
|
||||
assertInstance(b0, ICPPClassType.class);
|
||||
assertInstance(b1, ICPPTemplateInstance.class);
|
||||
assertInstance(b1, ICPPClassType.class);
|
||||
|
||||
|
||||
// ICPPClassType _ct= (ICPPClassType) b1;
|
||||
// ICPPConstructor[] _ctcs= _ct.getConstructors();
|
||||
// assertEquals(3, _ctcs.length); // two implicit plus the constructor template
|
||||
|
||||
|
||||
IBinding b2= getBindingFromASTName("D<int>(", 1);
|
||||
IBinding b3= getBindingFromASTName("D<int>(", 6);
|
||||
|
||||
|
||||
assertInstance(b2, ICPPClassTemplate.class); // *D*<int>(5, 6)
|
||||
assertInstance(b2, ICPPClassType.class); // *D*<int>(5, 6)
|
||||
assertInstance(b3, ICPPTemplateInstance.class); // *D<int>*(5, 6)
|
||||
assertInstance(b3, ICPPConstructor.class); // *D<int>*(5, 6)
|
||||
|
||||
|
||||
//
|
||||
// ICPPClassType ct= (ICPPClassType) b2;
|
||||
// ICPPConstructor[] ctcs= ct.getConstructors();
|
||||
// assertEquals(3, ctcs.length); // two implicit plus the constructor template
|
||||
|
||||
|
||||
IBinding tidSpc= ((ICPPTemplateInstance)b3).getSpecializedBinding();
|
||||
assertInstance(tidSpc, ICPPConstructor.class);
|
||||
assertInstance(tidSpc, ICPPSpecialization.class);
|
||||
|
@ -470,22 +470,22 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
IBinding b2= getBindingFromASTName("f.s.foo", 1);
|
||||
IBinding b3= getBindingFromASTName("s.foo", 1);
|
||||
IBinding b4= getBindingFromASTName("foo(*", 3);
|
||||
|
||||
|
||||
assertInstance(b0, ICPPClassTemplate.class);
|
||||
assertInstance(b0, ICPPClassType.class);
|
||||
ICPPTemplateParameter[] ps= ((ICPPClassTemplate)b0).getTemplateParameters();
|
||||
assertEquals(2, ps.length);
|
||||
assertInstance(ps[0], ICPPTemplateTypeParameter.class);
|
||||
assertInstance(ps[1], ICPPTemplateTemplateParameter.class);
|
||||
|
||||
|
||||
assertInstance(b1, ICPPTemplateInstance.class);
|
||||
assertInstance(b1, ICPPClassType.class);
|
||||
|
||||
|
||||
IType[] type= ((ICPPTemplateInstance)b1).getArguments();
|
||||
assertInstance(type[0], ICPPClassType.class);
|
||||
assertInstance(type[1], ICPPClassTemplate.class);
|
||||
assertInstance(type[1], ICPPClassType.class);
|
||||
|
||||
|
||||
ObjectMap om= ((ICPPTemplateInstance)b1).getArgumentMap();
|
||||
assertEquals(2, om.size());
|
||||
assertInstance(om.keyAt(0), ICPPTemplateTypeParameter.class);
|
||||
|
@ -493,7 +493,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(om.keyAt(1), ICPPTemplateTemplateParameter.class);
|
||||
assertInstance(om.getAt(1), ICPPClassType.class);
|
||||
assertInstance(om.getAt(1), ICPPClassTemplate.class);
|
||||
|
||||
|
||||
IBinding b1_spcd= ((ICPPTemplateInstance)b1).getSpecializedBinding();
|
||||
assertInstance(b1_spcd, ICPPClassTemplate.class);
|
||||
assertInstance(b1_spcd, ICPPClassType.class);
|
||||
|
@ -580,20 +580,20 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
IBinding b1= getBindingFromASTName("D<B, T3>", 8);
|
||||
IBinding b2= getBindingFromASTName("D<C, T3>", 8);
|
||||
IBinding b3= getBindingFromASTName("D<B", 1);
|
||||
|
||||
|
||||
List spBindings= new ArrayList();
|
||||
assertInstance(b0, ICPPSpecialization.class);
|
||||
assertInstance(b0, ICPPClassTemplate.class);
|
||||
spBindings.add(((ICPPSpecialization)b0).getSpecializedBinding());
|
||||
|
||||
|
||||
assertInstance(b1, ICPPSpecialization.class);
|
||||
assertInstance(b1, ICPPClassTemplate.class);
|
||||
spBindings.add(((ICPPSpecialization)b1).getSpecializedBinding());
|
||||
|
||||
|
||||
assertInstance(b2, ICPPSpecialization.class);
|
||||
assertInstance(b2, ICPPClassTemplate.class);
|
||||
spBindings.add(((ICPPSpecialization)b2).getSpecializedBinding());
|
||||
|
||||
|
||||
for(int i=0; i<spBindings.size(); i++) {
|
||||
for(int j=0; j<spBindings.size(); j++) {
|
||||
IType ty1= (IType) spBindings.get(i);
|
||||
|
@ -601,7 +601,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertTrue(ty1.isSameType(ty2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
assertInstance(b3, ICPPClassTemplate.class);
|
||||
ICPPClassTemplate ct= (ICPPClassTemplate) b3;
|
||||
assertEquals(3, ct.getPartialSpecializations().length);
|
||||
|
@ -668,7 +668,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// B foo(B t) { B x= *new B(); return x; }
|
||||
// void bar(B t, int& x) { x++; }
|
||||
// };
|
||||
|
||||
|
||||
// A<B> ab;
|
||||
public void testClassSpecializationMethods() throws Exception {
|
||||
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 bar= dms[0].getName().equals("bar") ? dms[0] : dms[1];
|
||||
|
||||
|
||||
assertEquals(foo.getName(), "foo");
|
||||
assertEquals(bar.getName(), "bar");
|
||||
|
||||
|
||||
assertInstance(foo.getType().getReturnType(), ICPPClassType.class);
|
||||
assertEquals(((ICPPClassType)foo.getType().getReturnType()).getName(), "B");
|
||||
assertEquals(foo.getType().getParameterTypes().length, 1);
|
||||
assertInstance(foo.getType().getParameterTypes()[0], ICPPClassType.class);
|
||||
assertEquals(((ICPPClassType)foo.getType().getParameterTypes()[0]).getName(), "B");
|
||||
|
||||
|
||||
assertInstance(bar.getType().getReturnType(), ICPPBasicType.class);
|
||||
assertEquals(((ICPPBasicType)bar.getType().getReturnType()).getType(), IBasicType.t_void);
|
||||
}
|
||||
|
||||
|
||||
// template<typename T> class A {
|
||||
// public:
|
||||
// typedef T TD;
|
||||
|
@ -807,25 +807,25 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(b0_ptypes[1], ICPPClassType.class);
|
||||
assertEquals("A", ((ICPPClassType)b0_ptypes[0]).getName());
|
||||
assertEquals("B", ((ICPPClassType)b0_ptypes[1]).getName());
|
||||
|
||||
|
||||
IParameter[] b0_pms= ((ICPPFunction)b0).getParameters();
|
||||
assertEquals(2, b0_pms.length);
|
||||
assertInstance(b0_pms[0].getType(), ICPPClassType.class);
|
||||
assertInstance(b0_pms[1].getType(), ICPPClassType.class);
|
||||
assertEquals("A", ((ICPPClassType)b0_pms[0].getType()).getName());
|
||||
assertEquals("B", ((ICPPClassType)b0_pms[1].getType()).getName());
|
||||
|
||||
|
||||
IBinding b0_spcd= ((ICPPTemplateInstance)b0).getSpecializedBinding();
|
||||
assertInstance(b0_spcd, ICPPFunction.class);
|
||||
assertInstance(b0_spcd, ICPPTemplateDefinition.class);
|
||||
|
||||
|
||||
IParameter[] b0_spcd_pms= ((ICPPFunction)b0_spcd).getParameters();
|
||||
assertEquals(2, b0_spcd_pms.length);
|
||||
assertInstance(b0_spcd_pms[0].getType(), ICPPTemplateTypeParameter.class);
|
||||
assertInstance(b0_spcd_pms[1].getType(), ICPPTemplateTypeParameter.class);
|
||||
assertEquals("T1", ((ICPPTemplateTypeParameter)b0_spcd_pms[0].getType()).getName());
|
||||
assertEquals("T2", ((ICPPTemplateTypeParameter)b0_spcd_pms[1].getType()).getName());
|
||||
|
||||
|
||||
ObjectMap b0_am= ((ICPPSpecialization)b0).getArgumentMap();
|
||||
assertEquals(2, b0_am.size());
|
||||
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("A", ((ICPPClassType)b0_am.getAt(0)).getName());
|
||||
assertEquals("B", ((ICPPClassType)b0_am.getAt(1)).getName());
|
||||
|
||||
|
||||
ICPPFunctionType b0_spcd_type= ((ICPPFunction)b0_spcd).getType();
|
||||
assertInstance(b0_spcd_type.getReturnType(), ICPPBasicType.class);
|
||||
IType[] b0_spcd_ptypes= b0_spcd_type.getParameterTypes();
|
||||
|
@ -845,7 +845,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(b0_spcd_ptypes[1], ICPPTemplateTypeParameter.class);
|
||||
assertEquals("T1", ((ICPPTemplateTypeParameter)b0_spcd_ptypes[0]).getName());
|
||||
assertEquals("T2", ((ICPPTemplateTypeParameter)b0_spcd_ptypes[1]).getName());
|
||||
|
||||
|
||||
IBinding b1= getBindingFromASTName("foo(c,a)", 3);
|
||||
assertInstance(b1, ICPPFunction.class);
|
||||
ICPPFunctionType b1type= ((ICPPFunction)b1).getType();
|
||||
|
@ -856,20 +856,20 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(b1_ptypes[1], ICPPClassType.class);
|
||||
assertEquals("C", ((ICPPClassType)b1_ptypes[0]).getName());
|
||||
assertEquals("A", ((ICPPClassType)b1_ptypes[1]).getName());
|
||||
|
||||
|
||||
IParameter[] b1_pms= ((ICPPFunction)b1).getParameters();
|
||||
assertEquals(2, b1_pms.length);
|
||||
assertInstance(b1_pms[0].getType(), ICPPClassType.class);
|
||||
assertInstance(b1_pms[1].getType(), ICPPClassType.class);
|
||||
assertEquals("C", ((ICPPClassType)b1_pms[0].getType()).getName());
|
||||
assertEquals("A", ((ICPPClassType)b1_pms[1].getType()).getName());
|
||||
|
||||
|
||||
assertInstance(b1, ICPPSpecialization.class);
|
||||
ICPPSpecialization b1s= (ICPPSpecialization) b1;
|
||||
IBinding b1_spcd= b1s.getSpecializedBinding();
|
||||
assertInstance(b1_spcd, ICPPFunction.class);
|
||||
assertInstance(b1_spcd, ICPPTemplateDefinition.class);
|
||||
|
||||
|
||||
ICPPFunctionType b1_spcd_type= ((ICPPFunction)b1_spcd).getType();
|
||||
assertInstance(b1_spcd_type.getReturnType(), ICPPBasicType.class);
|
||||
IType[] b1_spcd_ptypes= b1_spcd_type.getParameterTypes();
|
||||
|
@ -878,14 +878,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(b1_spcd_ptypes[1], ICPPTemplateTypeParameter.class);
|
||||
assertEquals("T1", ((ICPPTemplateTypeParameter)b1_spcd_ptypes[0]).getName());
|
||||
assertEquals("T2", ((ICPPTemplateTypeParameter)b1_spcd_ptypes[1]).getName());
|
||||
|
||||
|
||||
IParameter[] b1_spcd_pms= ((ICPPFunction)b1_spcd).getParameters();
|
||||
assertEquals(2, b1_spcd_pms.length);
|
||||
assertInstance(b1_spcd_pms[0].getType(), ICPPTemplateTypeParameter.class);
|
||||
assertInstance(b1_spcd_pms[1].getType(), ICPPTemplateTypeParameter.class);
|
||||
assertEquals("T1", ((ICPPTemplateTypeParameter)b1_spcd_pms[0].getType()).getName());
|
||||
assertEquals("T2", ((ICPPTemplateTypeParameter)b1_spcd_pms[1].getType()).getName());
|
||||
|
||||
|
||||
ObjectMap b1_am= b1s.getArgumentMap();
|
||||
assertEquals(2, b1_am.size());
|
||||
assertInstance(b1_am.keyAt(0), ICPPTemplateTypeParameter.class);
|
||||
|
@ -911,17 +911,17 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
IBinding b0= getBindingFromASTName("foo(a)", 3);
|
||||
assertInstance(b0, ICPPTemplateInstance.class);
|
||||
assertInstance(b0, ICPPFunction.class);
|
||||
|
||||
|
||||
ICPPFunction f= (ICPPFunction) b0;
|
||||
ICPPFunctionType type= f.getType();
|
||||
IType rt= type.getReturnType();
|
||||
IType[] pts= type.getParameterTypes();
|
||||
|
||||
|
||||
IParameter[] ps= f.getParameters();
|
||||
assertEquals(1, ps.length);
|
||||
ICPPParameter param= (ICPPParameter) ps[0];
|
||||
assertInstance(param, ICPPSpecialization.class);
|
||||
|
||||
|
||||
IType paramType= param.getType();
|
||||
assertInstance(paramType, ICPPClassType.class);
|
||||
ICPPParameter paramSpec= (ICPPParameter) ((ICPPSpecialization) param).getSpecializedBinding();
|
||||
|
@ -929,7 +929,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
ICPPTemplateTypeParameter ttp= (ICPPTemplateTypeParameter) paramSpec.getType();
|
||||
assertEquals("T", ttp.getName());
|
||||
assertNull(ttp.getDefault());
|
||||
|
||||
|
||||
ICPPTemplateInstance inst= (ICPPTemplateInstance) b0;
|
||||
IBinding sp= inst.getSpecializedBinding();
|
||||
assertInstance(sp, ICPPFunction.class);
|
||||
|
@ -994,10 +994,10 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testClassSpecializations_180738() {
|
||||
IBinding b1a = getBindingFromASTName("Foo<B> b1;", 3);
|
||||
IBinding b1b = getBindingFromASTName("Foo<B> b1;", 6);
|
||||
|
||||
|
||||
assertInstance(b1a, ICPPClassType.class);
|
||||
assertInstance(b1a, ICPPClassTemplate.class);
|
||||
|
||||
|
||||
assertInstance(b1b, ICPPClassType.class);
|
||||
assertInstance(b1b, ICPPSpecialization.class);
|
||||
ICPPSpecialization b1spc= (ICPPSpecialization) b1b;
|
||||
|
@ -1006,13 +1006,13 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(b1om.getAt(0), ICPPClassType.class);
|
||||
ICPPClassType b1pct= (ICPPClassType) b1om.getAt(0);
|
||||
assertEquals("B", b1pct.getName());
|
||||
|
||||
|
||||
IBinding b2a = getBindingFromASTName("Foo<B> b2;", 3);
|
||||
IBinding b2b = getBindingFromASTName("Foo<B> b2;", 6);
|
||||
|
||||
|
||||
assertInstance(b2a, ICPPClassType.class);
|
||||
assertInstance(b2a, ICPPClassTemplate.class);
|
||||
|
||||
|
||||
assertInstance(b2b, ICPPClassType.class);
|
||||
assertInstance(b2b, ICPPSpecialization.class);
|
||||
ICPPSpecialization b2spc= (ICPPSpecialization) b2b;
|
||||
|
@ -1122,21 +1122,21 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
IBinding ca= getBindingFromASTName("C<A>", 4);
|
||||
assertInstance(ca, ICPPClassType.class);
|
||||
assertInstance(ca, ICPPTemplateInstance.class);
|
||||
|
||||
|
||||
IBinding foo1= getBindingFromASTName("foo(c)", 3);
|
||||
|
||||
|
||||
IBinding da= getBindingFromASTName("D<A>", 4);
|
||||
assertInstance(da, ICPPClassType.class);
|
||||
assertInstance(da, ICPPTemplateInstance.class);
|
||||
|
||||
|
||||
IBinding foo2= getBindingFromASTName("foo(d)", 3);
|
||||
IBinding foo3= getBindingFromASTName("foo(e)", 3);
|
||||
IBinding foo4= getBindingFromASTName("foo(cx)", 3);
|
||||
|
||||
|
||||
assertEquals(foo1, foo2); assertEquals(foo2, foo3);
|
||||
assertEquals(foo3, foo4);
|
||||
}
|
||||
|
||||
|
||||
// template<typename T>
|
||||
// class A {};
|
||||
//
|
||||
|
@ -1144,7 +1144,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
//
|
||||
// template<>
|
||||
// class A<B> {};
|
||||
|
||||
|
||||
// class C {};
|
||||
//
|
||||
// A<B> ab;
|
||||
|
@ -1152,15 +1152,15 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testEnclosingScopes_a() throws Exception {
|
||||
ICPPSpecialization b0= getBindingFromASTName("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class);
|
||||
ICPPTemplateInstance b1= getBindingFromASTName("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
|
||||
|
||||
|
||||
ICPPClassType sc0= assertInstance(b0.getSpecializedBinding(), ICPPClassType.class);
|
||||
ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
|
||||
assertTrue(sc0.isSameType(sc1));
|
||||
|
||||
|
||||
assertNull(sc0.getScope());
|
||||
assertNull(b0.getScope());
|
||||
}
|
||||
|
||||
|
||||
// template<typename T>
|
||||
// class A {
|
||||
// public:
|
||||
|
@ -1174,7 +1174,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// public:
|
||||
// class B {};
|
||||
// };
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// void refs() {
|
||||
// A<C>::B acb;
|
||||
|
@ -1184,7 +1184,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
ICPPClassType b0= getBindingFromASTName("B acb", 1, ICPPClassType.class);
|
||||
ICPPClassType b1= getBindingFromASTName("B adb", 1, ICPPClassType.class, ICPPSpecialization.class);
|
||||
ICPPClassType b2= getBindingFromASTName("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class);
|
||||
|
||||
|
||||
IIndexBinding[] sr = getIndex().findBindings("A".toCharArray(), new IndexFilter() {
|
||||
@Override
|
||||
public boolean acceptBinding(IBinding binding) throws CoreException {
|
||||
|
@ -1193,7 +1193,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
}, npm());
|
||||
assertTrue(sr.length == 1);
|
||||
ICPPClassType b3= (ICPPClassType) sr[0];
|
||||
|
||||
|
||||
sr = getIndex().findBindings(new char[][] {"A".toCharArray(), "B".toCharArray()}, new IndexFilter() {
|
||||
@Override
|
||||
public boolean acceptBinding(IBinding binding) throws CoreException {
|
||||
|
@ -1202,19 +1202,19 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
}, npm());
|
||||
assertTrue(sr.length == 1);
|
||||
ICPPClassType b4= (ICPPClassType) sr[0];
|
||||
|
||||
|
||||
assertFalse(b0 instanceof ICPPSpecialization);
|
||||
|
||||
|
||||
IIndexScope s0= (IIndexScope) b0.getScope(), s4= (IIndexScope) b4.getScope();
|
||||
IScope s1= b1.getScope();
|
||||
|
||||
|
||||
assertTrue(((IType)s0.getScopeBinding()).isSameType((IType)((IIndexScope)b2.getCompositeScope()).getScopeBinding()));
|
||||
ICPPClassScope cs1= assertInstance(s1, ICPPClassScope.class);
|
||||
assertInstance(cs1.getClassType(), ICPPClassType.class);
|
||||
assertInstance(cs1.getClassType(), ICPPTemplateInstance.class);
|
||||
assertTrue(((IType)((ICPPClassSpecialization) s4.getScopeBinding()).getSpecializedBinding()).isSameType( (IType) ((IIndexScope)b3.getCompositeScope()).getScopeBinding() ));
|
||||
}
|
||||
|
||||
|
||||
// class A {};
|
||||
//
|
||||
// template<typename T>
|
||||
|
@ -1230,18 +1230,18 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testEnclosingScopes_c() throws Exception {
|
||||
ICPPClassType b0= getBindingFromASTName("Y::Z x", 1, ICPPClassType.class);
|
||||
ICPPClassType b1= getBindingFromASTName("Z xayz", 1, ICPPClassType.class);
|
||||
|
||||
|
||||
IScope s0= b0.getScope(), s1= b1.getScope();
|
||||
|
||||
|
||||
ICPPClassScope cs0= assertInstance(s0, ICPPClassScope.class);
|
||||
assertInstance(cs0.getClassType(), ICPPClassType.class);
|
||||
assertInstance(cs0.getClassType(), ICPPSpecialization.class);
|
||||
|
||||
|
||||
ICPPClassScope cs1= assertInstance(s1, ICPPClassScope.class);
|
||||
assertInstance(cs1.getClassType(), ICPPClassType.class);
|
||||
assertInstance(cs1.getClassType(), ICPPSpecialization.class);
|
||||
assertInstance(cs1.getClassType(), ICPPSpecialization.class);
|
||||
}
|
||||
|
||||
|
||||
// class A {}; class B {};
|
||||
//
|
||||
// template<typename T1, typename T2>
|
||||
|
@ -1252,21 +1252,21 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// public:
|
||||
// class N {};
|
||||
// };
|
||||
|
||||
|
||||
// X<B,A>::N n;
|
||||
public void testEnclosingScopes_d() throws Exception {
|
||||
ICPPClassType b0= getBindingFromASTName("N n", 1, ICPPClassType.class, ICPPSpecialization.class);
|
||||
ICPPClassType b1= assertInstance(((ICPPSpecialization) b0).getSpecializedBinding(), ICPPClassType.class);
|
||||
|
||||
|
||||
ICPPClassScope s0= assertInstance(b0.getScope(), ICPPClassScope.class);
|
||||
assertInstance(s0.getClassType(), ICPPTemplateInstance.class);
|
||||
|
||||
|
||||
ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class);
|
||||
assertInstance(s1.getClassType(), ICPPTemplateDefinition.class);
|
||||
|
||||
|
||||
assertNull(s1.getClassType().getScope());
|
||||
}
|
||||
|
||||
|
||||
// typedef signed int SI;
|
||||
//
|
||||
// template <SI x>
|
||||
|
@ -1282,16 +1282,16 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(args.keyAt(0), ICPPTemplateNonTypeParameter.class);
|
||||
assertEquals(1, args.size());
|
||||
}
|
||||
|
||||
// template <class T> class A {
|
||||
// class B { T t; };
|
||||
// B b;
|
||||
// };
|
||||
|
||||
// void f() {
|
||||
// A<int> a;
|
||||
// a.b.t;
|
||||
// }
|
||||
|
||||
// template <class T> class A {
|
||||
// class B { T t; };
|
||||
// B b;
|
||||
// };
|
||||
|
||||
// void f() {
|
||||
// A<int> a;
|
||||
// a.b.t;
|
||||
// }
|
||||
public void testNestedClassTypeSpecializations() throws Exception {
|
||||
ICPPField t2 = getBindingFromASTName("t;", 1, ICPPField.class);
|
||||
|
||||
|
@ -1312,7 +1312,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// template<typename _Iterator, typename _Container> class normal_iterator {
|
||||
// protected:
|
||||
// _Iterator _M_current;
|
||||
//
|
||||
//
|
||||
// public:
|
||||
// typedef typename iterator_traits<_Iterator>::pointer pointer;
|
||||
// normal_iterator() : _M_current(_Iterator()) { }
|
||||
|
@ -1349,7 +1349,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
ICPPField t2 = getBindingFromASTName("member; // it->member", 6, ICPPField.class);
|
||||
ICPPClassType ct= t2.getClassOwner();
|
||||
assertEquals("MyStruct", ct.getName());
|
||||
|
||||
|
||||
final IType type = t2.getType();
|
||||
assertTrue(type instanceof IBasicType);
|
||||
assertEquals(((IBasicType)type).getType(), IBasicType.t_int);
|
||||
|
@ -1382,7 +1382,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
ICPPTemplateArgument arg = paramMap.getArgument(0);
|
||||
assertEquals(Long.valueOf(256), arg.getNonTypeValue().numericalValue());
|
||||
assertInstance(arg.getTypeOfNonTypeValue(), ICPPBasicType.class);
|
||||
|
||||
|
||||
ICPPFunction foo = getBindingFromASTName("foo(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 b3= getBindingFromASTName("A<B, 'y'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
|
||||
ICPPClassType b4= getBindingFromASTName("A<B, 'z'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
|
||||
|
||||
|
||||
assertTrue(!b2.isSameType(b3));
|
||||
assertTrue(!b3.isSameType(b4));
|
||||
assertTrue(!b4.isSameType(b2));
|
||||
|
||||
|
||||
ICPPClassType X= getBindingFromASTName("X x", 1, ICPPClassType.class);
|
||||
ICPPClassType Y= getBindingFromASTName("Y y", 1, ICPPClassType.class);
|
||||
ICPPClassType Z= getBindingFromASTName("Z z", 1, ICPPClassType.class);
|
||||
|
||||
|
||||
assertTrue(!X.isSameType(Y));
|
||||
assertTrue(!Y.isSameType(Z));
|
||||
assertTrue(!Z.isSameType(X));
|
||||
|
@ -1429,7 +1429,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
ICPPClassType Y= getBindingFromASTName("Y y; //2", 1, ICPPClassType.class);
|
||||
getProblemFromASTName("X x; //3", 1);
|
||||
getProblemFromASTName("Y y; //4", 1);
|
||||
|
||||
|
||||
assertTrue(!X.isSameType(Y));
|
||||
}
|
||||
|
||||
|
@ -1453,12 +1453,12 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
ICPPClassType a5c= getBindingFromASTName("A<FUNF>", 7, ICPPClassType.class, ICPPSpecialization.class);
|
||||
ICPPClassType a5d= getBindingFromASTName("A<5>", 4, ICPPClassType.class, ICPPSpecialization.class);
|
||||
ICPPClassType a1= getBindingFromASTName("A<1>", 4, ICPPClassType.class, ICPPTemplateInstance.class);
|
||||
|
||||
|
||||
assertTrue(a5a.isSameType(a5b));
|
||||
assertTrue(a5b.isSameType(a5c));
|
||||
assertTrue(a5c.isSameType(a5d));
|
||||
assertTrue(a5d.isSameType(a5a));
|
||||
|
||||
|
||||
assertTrue(!a1.isSameType(a5a));
|
||||
assertTrue(!a1.isSameType(a5b));
|
||||
assertTrue(!a1.isSameType(a5c));
|
||||
|
@ -1489,7 +1489,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
ICPPConstructor th1sCtor= ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
|
||||
assertFalse(th1sCtor instanceof ICPPSpecialization);ICPPTemplateNonTypeParameter np= ba.assertNonProblem("I)", 1, ICPPTemplateNonTypeParameter.class);
|
||||
*/
|
||||
|
||||
|
||||
ICPPTemplateNonTypeParameter np= getBindingFromASTName("I>(I)", 1, ICPPTemplateNonTypeParameter.class);
|
||||
ICPPConstructor clazz= getBindingFromASTName("That<I>(I)", 4, ICPPConstructor.class);
|
||||
ICPPConstructor ctor= getBindingFromASTName("That<I>(I)", 7, ICPPConstructor.class);
|
||||
|
@ -1515,7 +1515,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertFalse(tid instanceof ICPPSpecialization);
|
||||
ICPPConstructor th1sCtor= getBindingFromASTName("This() :", 4, ICPPConstructor.class);
|
||||
assertFalse(th1sCtor instanceof ICPPSpecialization);
|
||||
|
||||
|
||||
ICPPTemplateTypeParameter np= getBindingFromASTName("I>()", 1, ICPPTemplateTypeParameter.class);
|
||||
ICPPConstructor clazz= getBindingFromASTName("That<I>()", 4, 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 {
|
||||
ICPPVariable v1= getBindingFromASTName("v1", 2, ICPPVariable.class);
|
||||
ICPPVariable v2= getBindingFromASTName("v1", 2, ICPPVariable.class);
|
||||
|
||||
|
||||
IType t1= v1.getType();
|
||||
assertInstance(t1, ICPPClassType.class);
|
||||
|
||||
|
||||
ICPPClassType ct= (ICPPClassType) t1;
|
||||
IBinding f1= ct.getCompositeScope().find("field")[0];
|
||||
IBinding f2= ct.getCompositeScope().find("field")[0];
|
||||
|
||||
|
||||
assertSame(f1, f2);
|
||||
}
|
||||
|
||||
|
@ -1549,15 +1549,15 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testUniqueInstance_Bug241641() throws Exception {
|
||||
IASTName name= findName("v1", 2);
|
||||
ICPPVariable v1= getBindingFromASTName("v1", 2, ICPPVariable.class);
|
||||
|
||||
|
||||
IType t1= v1.getType();
|
||||
assertInstance(t1, ICPPTemplateInstance.class);
|
||||
|
||||
|
||||
ICPPTemplateInstance inst= (ICPPTemplateInstance) t1;
|
||||
final ICPPClassTemplate tmplDef = (ICPPClassTemplate) inst.getTemplateDefinition();
|
||||
IBinding inst2= CPPTemplates.instantiate(tmplDef, inst.getTemplateArguments(), name);
|
||||
assertSame(inst, inst2);
|
||||
|
||||
|
||||
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);
|
||||
assertSame(charInst1, charInst2);
|
||||
|
@ -1582,9 +1582,9 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
}
|
||||
|
||||
// template<class T, class U> class A {};
|
||||
// template<class T> class A<T, int> {
|
||||
// void foo(T t);
|
||||
// };
|
||||
// template<class T> class A<T, int> {
|
||||
// void foo(T t);
|
||||
// };
|
||||
|
||||
// template<class T> void A<T, int>::foo(T t) {}
|
||||
public void testBug177418() throws Exception {
|
||||
|
@ -1592,8 +1592,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
ICPPClassType owner= m.getClassOwner();
|
||||
assertInstance(owner, ICPPClassTemplatePartialSpecialization.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// template<typename T> class XT {
|
||||
// int f;
|
||||
// void m();
|
||||
|
@ -1610,13 +1610,13 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertFalse(m instanceof ICPPUnknownBinding);
|
||||
m= getBindingFromASTName("m(); // 2", 1, ICPPMethod.class);
|
||||
assertFalse(m instanceof ICPPUnknownBinding);
|
||||
|
||||
|
||||
ICPPField f= getBindingFromASTName("f; // 1", 1, ICPPField.class);
|
||||
assertFalse(f instanceof ICPPUnknownBinding);
|
||||
f= getBindingFromASTName("f; // 2", 1, ICPPField.class);
|
||||
assertFalse(f instanceof ICPPUnknownBinding);
|
||||
}
|
||||
|
||||
|
||||
// template <typename T= int> class XT;
|
||||
|
||||
// #include "header.h"
|
||||
|
@ -1769,7 +1769,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertFalse(inst.isExplicitSpecialization());
|
||||
inst = getBindingFromASTName("Y<int>", 0);
|
||||
assertTrue(inst.isExplicitSpecialization());
|
||||
|
||||
|
||||
inst = getBindingFromASTName("f(1)", 1);
|
||||
assertFalse(inst.isExplicitSpecialization());
|
||||
inst = getBindingFromASTName("g(1)", 1);
|
||||
|
@ -1819,7 +1819,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// };
|
||||
// int main() {
|
||||
// A<float, int> a;
|
||||
// a.f(0);
|
||||
// a.f(0);
|
||||
// return 0;
|
||||
// }
|
||||
public void testPartialSpecializationsOfClassTemplateSpecializations_332884() throws Exception {
|
||||
|
@ -1844,16 +1844,16 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
ICPPClassType ct= getBindingFromASTName("TXT", 0, ICPPClassType.class);
|
||||
ICPPMethod[] methods = ct.getAllDeclaredMethods();
|
||||
assertEquals(2, methods.length);
|
||||
|
||||
|
||||
methods= ct.getConstructors();
|
||||
assertEquals(2, methods.length);
|
||||
|
||||
methods= ct.getMethods();
|
||||
assertEquals(14, methods.length);
|
||||
|
||||
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(ct, null);
|
||||
assertEquals(1, bases.length);
|
||||
|
||||
|
||||
IField field = ct.findField("bfield");
|
||||
assertNotNull(field);
|
||||
|
||||
|
@ -2034,12 +2034,12 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testSFINAE_b() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
|
||||
// struct CString {
|
||||
// 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;
|
||||
// };
|
||||
|
||||
|
||||
// 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 {
|
||||
// }
|
||||
|
@ -2061,4 +2061,118 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testAliasTemplate() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// template<typename U>
|
||||
// struct A {
|
||||
// typedef U type1;
|
||||
//
|
||||
// template<typename V>
|
||||
// struct rebind {
|
||||
// typedef A<V> other;
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// template<typename T, typename U>
|
||||
// struct B {
|
||||
// template<typename T2, typename U2>
|
||||
// static constexpr bool test(typename T2::template rebind<U2>::other*) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// template<typename, typename>
|
||||
// static constexpr bool test(...) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// static const bool value = test<T, U>(nullptr);
|
||||
// };
|
||||
//
|
||||
// template<typename T, typename U, bool = B<T, U>::value>
|
||||
// struct C;
|
||||
//
|
||||
// template<typename T, typename U>
|
||||
// struct C<T, U, true> {
|
||||
// typedef typename T::template rebind<U>::other type2;
|
||||
// };
|
||||
//
|
||||
// template<typename T1>
|
||||
// struct D {
|
||||
// typedef typename T1::type1 type3;
|
||||
//
|
||||
// template<typename U1>
|
||||
// using rebind2 = typename C<T1, U1>::type2;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct E : D<T> {
|
||||
// typedef D<T> Base;
|
||||
// typedef typename Base::type3& type4;
|
||||
//
|
||||
// template<typename U>
|
||||
// struct rebind {
|
||||
// typedef typename Base::template rebind2<U> other;
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// template<typename U, typename T = A<U>>
|
||||
// struct F {
|
||||
// typedef typename E<T>::template rebind<U>::other type5;
|
||||
// typedef typename E<type5>::type4 type6;
|
||||
// type6 operator[](int n);
|
||||
// };
|
||||
//
|
||||
// void f(int);
|
||||
|
||||
// void test() {
|
||||
// F<int*> a;
|
||||
// f(*a[0]);
|
||||
// }
|
||||
public void testConstexprFunction_395238_1() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct A {
|
||||
// template<typename U>
|
||||
// static constexpr U test(U v) {
|
||||
// return v;
|
||||
// }
|
||||
//
|
||||
// template<typename>
|
||||
// static constexpr bool test(...) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// static const bool value = test<T>(true);
|
||||
// };
|
||||
//
|
||||
// template<typename T, bool = A<T>::value>
|
||||
// struct B;
|
||||
//
|
||||
// template<typename T>
|
||||
// struct B<T, true> {
|
||||
// typedef T type;
|
||||
// };
|
||||
|
||||
// B<bool>::type x;
|
||||
// B<int*>::type y;
|
||||
public void testConstexprFunction_395238_2() throws Exception {
|
||||
ITypedef td = getBindingFromASTName("type x", 4, ITypedef.class);
|
||||
assertEquals("bool", ASTTypeUtil.getType(td.getType()));
|
||||
getProblemFromASTName("type y", 4);
|
||||
}
|
||||
|
||||
// template <class RandomAccessRange, class BinaryPredicate>
|
||||
// void sort(const RandomAccessRange& rng, BinaryPredicate pred);
|
||||
//
|
||||
// struct S {};
|
||||
// const S* s[5];
|
||||
|
||||
// template <typename BinaryPredicate>
|
||||
// void test(BinaryPredicate bp) {
|
||||
// sort(s, [&bp](const S* a, const S* b){ return bp(*a, *b); });
|
||||
// }
|
||||
public void testLambdaExpression_395884() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,10 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
public class BaseTestCase extends TestCase {
|
||||
protected static final int INDEXER_TIMEOUT_SEC = 10;
|
||||
private static final String DEFAULT_INDEXER_TIMEOUT_SEC = "10";
|
||||
private static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout";
|
||||
protected static final int INDEXER_TIMEOUT_SEC =
|
||||
Integer.parseInt(System.getProperty(INDEXER_TIMEOUT_PROPERTY, DEFAULT_INDEXER_TIMEOUT_SEC));
|
||||
private boolean fExpectFailure;
|
||||
private int fBugNumber;
|
||||
private int fExpectedLoggedNonOK;
|
||||
|
@ -160,7 +163,7 @@ public class BaseTestCase extends TestCase {
|
|||
try {
|
||||
super.runBare();
|
||||
} catch (Throwable e) {
|
||||
testThrowable=e;
|
||||
testThrowable= e;
|
||||
}
|
||||
|
||||
if (statusLog.size() != fExpectedLoggedNonOK) {
|
||||
|
@ -168,7 +171,7 @@ public class BaseTestCase extends TestCase {
|
|||
msg.append("non-OK status objects in log differs from actual (" + statusLog.size() + ").\n");
|
||||
Throwable cause= null;
|
||||
if (!statusLog.isEmpty()) {
|
||||
synchronized(statusLog) {
|
||||
synchronized (statusLog) {
|
||||
for (IStatus status : statusLog) {
|
||||
IStatus[] ss= {status};
|
||||
ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss;
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPQualifierType;
|
||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
@ -310,10 +311,18 @@ public class ASTTypeUtil {
|
|||
if (needSpace) result.append(SPACE);
|
||||
result.append(Keywords.FLOAT);
|
||||
break;
|
||||
case eFloat128:
|
||||
if (needSpace) result.append(SPACE);
|
||||
result.append(GCCKeywords.__FLOAT128);
|
||||
break;
|
||||
case eInt:
|
||||
if (needSpace) result.append(SPACE);
|
||||
result.append(Keywords.INT);
|
||||
break;
|
||||
case eInt128:
|
||||
if (needSpace) result.append(SPACE);
|
||||
result.append(GCCKeywords.__INT128);
|
||||
break;
|
||||
case eVoid:
|
||||
if (needSpace) result.append(SPACE);
|
||||
result.append(Keywords.VOID);
|
||||
|
|
|
@ -20,7 +20,7 @@ public interface IASTBinaryTypeIdExpression extends IASTExpression {
|
|||
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}
|
||||
|
||||
|
|
|
@ -48,28 +48,32 @@ public interface IBinding extends IAdaptable {
|
|||
* Returns the binding that owns this binding, or <code>null</code> if there is no owner.
|
||||
* <p>
|
||||
* The owner is determined as follows:
|
||||
* <br> {@link ICPPUsingDeclaration}: The owner depends on where the declaration is found, within a
|
||||
* function or method, a class-type, a namespace or on global scope.
|
||||
* <br> {@link ICPPUsingDeclaration}: The owner depends on where the declaration is found,
|
||||
* within a function or method, a class-type, a namespace or on global scope.
|
||||
* <br> {@link ICPPTemplateParameter}: The owner is the {@link ICPPTemplateDefinition}.
|
||||
* <br> {@link IEnumerator}: The owner is the {@link IEnumeration}, independent of whether they are scoped or not.
|
||||
* <br> For all other bindings: The owner depends on where the binding can be defined (it could be
|
||||
* declared else where).
|
||||
* <br> {@link IEnumerator}: The owner is the {@link IEnumeration}, independent of whether they
|
||||
* are scoped or not.
|
||||
* <br> For all other bindings: The owner depends on where the binding can be defined (it could
|
||||
* be declared elsewhere).
|
||||
* <p> Possible owners are:
|
||||
* <br> {@link IFunction}: for parameters, local types, variables, enumerators, labels and using declarations;
|
||||
* <br> {@link ICPPClassType}: for class-, struct- and union-members, even if the composite type is anonymous;
|
||||
* also for enumerators and using declarations;
|
||||
* <br> {@link ICompositeType}: for struct- and union-members, even if the composite type is anonymous;
|
||||
* also for anonymous structs or unions found within another struct;
|
||||
* <br> {@link ICPPNamespace}: for global types, functions, variables, enumerators, namespaces and using declarations;
|
||||
* <br> {@link IFunction}: for parameters, local types, variables, enumerators, labels and using
|
||||
* declarations;
|
||||
* <br> Closure represented by {@link ICPPClassType}: for lambda expression parameters;
|
||||
* <br> {@link ICPPClassType}: for class-, struct- and union-members, even if the composite type
|
||||
* is anonymous; also for enumerators and using declarations;
|
||||
* <br> {@link ICompositeType}: for struct- and union-members, even if the composite type is
|
||||
* anonymous; also for anonymous structs or unions found within another struct;
|
||||
* <br> {@link ICPPNamespace}: for global types, functions, variables, enumerators, namespaces
|
||||
* and using declarations;
|
||||
* <br> {@link IEnumeration}: for enumerators.
|
||||
* <br> <code>null</code>: for types, functions, variables, namespaces and using declarations;
|
||||
* <br> {@code null}: for types, functions, variables, namespaces and using declarations;
|
||||
* @since 5.1
|
||||
*/
|
||||
public IBinding getOwner();
|
||||
|
||||
/**
|
||||
* Returns the parent scope for this binding. A binding may have declarations in multiple scopes,
|
||||
* this method returns the scope where the binding would potentially be defined.
|
||||
* Returns the parent scope for this binding. A binding may have declarations in multiple
|
||||
* scopes, this method returns the scope where the binding would potentially be defined.
|
||||
*/
|
||||
public IScope getScope() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
@ -16,57 +17,63 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
|
||||
/**
|
||||
* Binding for c++ functions.
|
||||
*
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
*/
|
||||
public interface ICPPFunction extends IFunction, ICPPBinding {
|
||||
/**
|
||||
* Does this function have the mutable storage class specifier
|
||||
*/
|
||||
public boolean isMutable();
|
||||
|
||||
/**
|
||||
* Is this an inline function
|
||||
*/
|
||||
@Override
|
||||
* Does this function have the mutable storage class specifier
|
||||
*/
|
||||
public boolean isMutable();
|
||||
|
||||
/**
|
||||
* Is this an inline function
|
||||
*/
|
||||
@Override
|
||||
public boolean isInline();
|
||||
|
||||
/**
|
||||
* Returns whether this function is declared as extern "C".
|
||||
* @since 5.0
|
||||
*/
|
||||
public boolean isExternC();
|
||||
|
||||
/**
|
||||
* Returns the exception specification for this function or <code>null</code> if there
|
||||
* is no exception specification.
|
||||
* @since 5.1
|
||||
*/
|
||||
public IType[] getExceptionSpecification();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
||||
/**
|
||||
* Returns whether this function is declared as extern "C".
|
||||
* @since 5.0
|
||||
*/
|
||||
public boolean isExternC();
|
||||
|
||||
/**
|
||||
* Returns whether this function is declared constexpr.
|
||||
* @since 5.5
|
||||
*/
|
||||
public boolean isConstexpr();
|
||||
|
||||
/**
|
||||
* Returns the exception specification for this function or <code>null</code> if there
|
||||
* is no exception specification.
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
public IType[] getExceptionSpecification();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
public ICPPFunctionType getType();
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public ICPPParameter[] getParameters();
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public int getRequiredArgumentCount();
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @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.
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - Initial API and implementation
|
||||
* Andrew Niefer (IBM Corporation) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -42,9 +43,7 @@ public class ObjectMap extends ObjectTable<Object> {
|
|||
@Override
|
||||
final public void clear() {
|
||||
super.clear();
|
||||
for(int i = 0; i < valueTable.length; i++) {
|
||||
valueTable[i] = null;
|
||||
}
|
||||
Arrays.fill(valueTable, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
|
@ -74,7 +74,8 @@ public class ASTInternal {
|
|||
}
|
||||
}
|
||||
|
||||
public static IASTNode getDeclaredInSourceFileOnly(IIndexFragment forFragment, IBinding binding, boolean requireDefinition, PDOMBinding nonLocal) {
|
||||
public static IASTNode getDeclaredInSourceFileOnly(IIndexFragment forFragment, IBinding binding,
|
||||
boolean requireDefinition, PDOMBinding glob) {
|
||||
IASTNode[] decls;
|
||||
IASTNode def;
|
||||
if (binding instanceof ICPPInternalBinding) {
|
||||
|
@ -110,9 +111,9 @@ public class ASTInternal {
|
|||
if (result == null)
|
||||
return null;
|
||||
|
||||
if (requireDefinition && nonLocal != null) {
|
||||
if (requireDefinition && glob != null) {
|
||||
try {
|
||||
if (nonLocal.hasDeclaration())
|
||||
if (glob.hasDeclaration())
|
||||
return null;
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
|
|
@ -417,8 +417,9 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
copy.fForContentAssist = fForContentAssist;
|
||||
copy.fOriginatingTranslationUnit = fOriginatingTranslationUnit;
|
||||
|
||||
for (IASTDeclaration declaration : getDeclarations())
|
||||
for (IASTDeclaration declaration : getDeclarations()) {
|
||||
copy.addDeclaration(declaration == null ? null : declaration.copy(style));
|
||||
}
|
||||
|
||||
copy.setOffsetAndLength(this);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public abstract class ArithmeticConversion {
|
|||
eComplex(IBasicType.IS_COMPLEX);
|
||||
|
||||
private final int fModifier;
|
||||
|
||||
private Domain(int modifier) {
|
||||
fModifier= modifier;
|
||||
}
|
||||
|
@ -120,11 +121,13 @@ public abstract class ArithmeticConversion {
|
|||
case eChar16:
|
||||
case eChar32:
|
||||
case eInt:
|
||||
case eInt128:
|
||||
case eWChar:
|
||||
return true;
|
||||
|
||||
case eDouble:
|
||||
case eFloat:
|
||||
case eFloat128:
|
||||
case eUnspecified:
|
||||
case eVoid:
|
||||
case eNullPtr:
|
||||
|
@ -219,6 +222,7 @@ public abstract class ArithmeticConversion {
|
|||
case eWChar:
|
||||
case eChar16:
|
||||
return createBasicType(Kind.eInt, domain.getModifier());
|
||||
|
||||
case eChar32:
|
||||
// Assuming 32 bits
|
||||
return createBasicType(Kind.eInt, domain.getModifier() | IBasicType.IS_UNSIGNED);
|
||||
|
@ -227,11 +231,15 @@ public abstract class ArithmeticConversion {
|
|||
if (bt.isShort())
|
||||
return createBasicType(Kind.eInt, domain.getModifier());
|
||||
return adjustDomain(bt, domain);
|
||||
|
||||
|
||||
case eInt128:
|
||||
return createBasicType(Kind.eInt128, domain.getModifier() | IBasicType.IS_UNSIGNED);
|
||||
|
||||
case eVoid:
|
||||
case eUnspecified:
|
||||
case eDouble:
|
||||
case eFloat:
|
||||
case eFloat128:
|
||||
case eNullPtr:
|
||||
assert false;
|
||||
}
|
||||
|
@ -271,6 +279,8 @@ public abstract class ArithmeticConversion {
|
|||
}
|
||||
|
||||
private Rank getIntegerRank(IBasicType type) {
|
||||
if (type.getKind() == Kind.eInt128)
|
||||
return Rank.eLongLong;
|
||||
assert type.getKind() == Kind.eInt;
|
||||
if (type.isLongLong())
|
||||
return Rank.eLongLong;
|
||||
|
@ -282,7 +292,7 @@ public abstract class ArithmeticConversion {
|
|||
private boolean isLongDouble(IType type) {
|
||||
if (type instanceof IBasicType) {
|
||||
final IBasicType bt= (IBasicType) type;
|
||||
return bt.isLong() && bt.getKind() == Kind.eDouble;
|
||||
return bt.isLong() && bt.getKind() == Kind.eDouble || bt.getKind() == Kind.eFloat128;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryTypeIdExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
@ -54,13 +55,13 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||
|
@ -77,6 +78,20 @@ public class Value implements IValue {
|
|||
public static final Value UNKNOWN= new Value("<unknown>".toCharArray(), null); //$NON-NLS-1$
|
||||
public static final Value NOT_INITIALIZED= new Value("<__>".toCharArray(), null); //$NON-NLS-1$
|
||||
|
||||
private static final Number VALUE_CANNOT_BE_DETERMINED = new Number() {
|
||||
@Override
|
||||
public int intValue() { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public long longValue() { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public float floatValue() { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public double doubleValue() { throw new UnsupportedOperationException(); }
|
||||
};
|
||||
|
||||
private static final char UNIQUE_CHAR = '_';
|
||||
|
||||
private final static IValue[] TYPICAL= {
|
||||
|
@ -89,8 +104,6 @@ public class Value implements IValue {
|
|||
new Value(new char[] {'6'}, null)};
|
||||
|
||||
|
||||
private static class UnknownValueException extends Exception {}
|
||||
private static UnknownValueException UNKNOWN_EX= new UnknownValueException();
|
||||
private static int sUnique= 0;
|
||||
|
||||
// The following invariant always holds: (fFixedValue == null) != (fEvaluation == null)
|
||||
|
@ -213,7 +226,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) {
|
||||
return create(value ? 1 : 0);
|
||||
|
@ -235,44 +248,40 @@ public class Value implements IValue {
|
|||
}
|
||||
|
||||
public static IValue evaluateBinaryExpression(final int op, final long v1, final long v2) {
|
||||
try {
|
||||
return create(applyBinaryOperator(op, v1, v2));
|
||||
} catch (UnknownValueException e) {
|
||||
}
|
||||
Number val = applyBinaryOperator(op, v1, v2);
|
||||
if (val != null && val != VALUE_CANNOT_BE_DETERMINED)
|
||||
return create(val.longValue());
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public static IValue evaluateUnaryExpression(final int unaryOp, final long value) {
|
||||
try {
|
||||
return create(applyUnaryOperator(unaryOp, value));
|
||||
} catch (UnknownValueException e) {
|
||||
}
|
||||
Number val = applyUnaryOperator(unaryOp, value);
|
||||
if (val != null && val != VALUE_CANNOT_BE_DETERMINED)
|
||||
return create(val.longValue());
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public static IValue evaluateUnaryTypeIdExpression(int operator, IType type, IASTNode point) {
|
||||
try {
|
||||
return create(applyUnaryTypeIdOperator(operator, type, point));
|
||||
} catch (UnknownValueException e) {
|
||||
}
|
||||
Number val = applyUnaryTypeIdOperator(operator, type, point);
|
||||
if (val != null && val != VALUE_CANNOT_BE_DETERMINED)
|
||||
return create(val.longValue());
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public static IValue evaluateBinaryTypeIdExpression(IASTBinaryTypeIdExpression.Operator operator,
|
||||
IType type1, IType type2, IASTNode point) {
|
||||
try {
|
||||
return create(applyBinaryTypeIdOperator(operator, type1, type2, point));
|
||||
} catch (UnknownValueException e) {
|
||||
}
|
||||
Number val = applyBinaryTypeIdOperator(operator, type1, type2, point);
|
||||
if (val != null && val != VALUE_CANNOT_BE_DETERMINED)
|
||||
return create(val.longValue());
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
private static long applyUnaryTypeIdOperator(int operator, IType type, IASTNode point) throws UnknownValueException{
|
||||
private static Number applyUnaryTypeIdOperator(int operator, IType type, IASTNode point) {
|
||||
switch (operator) {
|
||||
case op_sizeof:
|
||||
return getSizeAndAlignment(type, point).size;
|
||||
return getSize(type, point);
|
||||
case op_alignof:
|
||||
return getSizeAndAlignment(type, point).alignment;
|
||||
return getAlignment(type, point);
|
||||
case op_typeid:
|
||||
break; // TODO(sprigogin): Implement
|
||||
case op_has_nothrow_copy:
|
||||
|
@ -318,40 +327,44 @@ public class Value implements IValue {
|
|||
case op_typeof:
|
||||
break; // TODO(sprigogin): Implement
|
||||
}
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
|
||||
public static long applyBinaryTypeIdOperator(IASTBinaryTypeIdExpression.Operator operator,
|
||||
IType type1, IType type2, IASTNode point) throws UnknownValueException {
|
||||
public static Number applyBinaryTypeIdOperator(IASTBinaryTypeIdExpression.Operator operator,
|
||||
IType type1, IType type2, IASTNode point) {
|
||||
switch (operator) {
|
||||
case __is_base_of:
|
||||
if (type1 instanceof ICPPClassType && type1 instanceof ICPPClassType) {
|
||||
return ClassTypeHelper.isSubclass((ICPPClassType) type2, (ICPPClassType) type1) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
|
||||
private static SizeAndAlignment getSizeAndAlignment(IType type, IASTNode point) throws UnknownValueException {
|
||||
private static Number getAlignment(IType type, IASTNode point) {
|
||||
SizeAndAlignment sizeAndAlignment = SizeofCalculator.getSizeAndAlignment(type, point);
|
||||
if (sizeAndAlignment == null)
|
||||
throw UNKNOWN_EX;
|
||||
return sizeAndAlignment;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
return sizeAndAlignment.alignment;
|
||||
}
|
||||
|
||||
private static Number getSize(IType type, IASTNode point) {
|
||||
SizeAndAlignment sizeAndAlignment = SizeofCalculator.getSizeAndAlignment(type, point);
|
||||
if (sizeAndAlignment == null)
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
return sizeAndAlignment.size;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* parameter.
|
||||
*/
|
||||
public static int isTemplateParameter(IValue tval) {
|
||||
ICPPEvaluation eval = tval.getEvaluation();
|
||||
if (eval instanceof EvalBinding) {
|
||||
IBinding binding = ((EvalBinding) eval).getBinding();
|
||||
if (binding instanceof ICPPTemplateParameter) {
|
||||
return ((ICPPTemplateParameter) binding).getParameterID();
|
||||
}
|
||||
return ((EvalBinding) eval).getTemplateParameterID();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -380,16 +393,15 @@ public class Value implements IValue {
|
|||
* Creates the value for an expression.
|
||||
*/
|
||||
public static IValue create(IASTExpression expr, int maxRecursionDepth) {
|
||||
try {
|
||||
Object obj= evaluate(expr, maxRecursionDepth);
|
||||
if (obj instanceof Long)
|
||||
return create(((Long) obj).longValue());
|
||||
Number val= evaluate(expr, maxRecursionDepth);
|
||||
if (val == VALUE_CANNOT_BE_DETERMINED)
|
||||
return UNKNOWN;
|
||||
if (val != null)
|
||||
return create(val.longValue());
|
||||
|
||||
if (expr instanceof ICPPASTInitializerClause) {
|
||||
ICPPEvaluation evaluation = ((ICPPASTInitializerClause) expr).getEvaluation();
|
||||
return new Value(null, evaluation);
|
||||
}
|
||||
} catch (UnknownValueException e) {
|
||||
if (expr instanceof ICPPASTInitializerClause) {
|
||||
ICPPEvaluation evaluation = ((ICPPASTInitializerClause) expr).getEvaluation();
|
||||
return new Value(null, evaluation);
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
@ -413,15 +425,15 @@ public class Value implements IValue {
|
|||
|
||||
/**
|
||||
* Computes the canonical representation of the value of the expression.
|
||||
* Returns a {@code Long} for numerical values or {@code null}, otherwise.
|
||||
* Returns a {@code Number} for numerical values or {@code null}, otherwise.
|
||||
* @throws UnknownValueException
|
||||
*/
|
||||
private static Long evaluate(IASTExpression exp, int maxdepth) throws UnknownValueException {
|
||||
private static Number evaluate(IASTExpression exp, int maxdepth) {
|
||||
if (maxdepth < 0 || exp == null)
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
|
||||
if (exp instanceof IASTArraySubscriptExpression) {
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
if (exp instanceof IASTBinaryExpression) {
|
||||
return evaluateBinaryExpression((IASTBinaryExpression) exp, maxdepth);
|
||||
|
@ -434,9 +446,9 @@ public class Value implements IValue {
|
|||
}
|
||||
if (exp instanceof IASTConditionalExpression) {
|
||||
IASTConditionalExpression cexpr= (IASTConditionalExpression) exp;
|
||||
Long v= evaluate(cexpr.getLogicalConditionExpression(), maxdepth);
|
||||
if (v == null)
|
||||
return null;
|
||||
Number v= evaluate(cexpr.getLogicalConditionExpression(), maxdepth);
|
||||
if (v == null || v == VALUE_CANNOT_BE_DETERMINED)
|
||||
return v;
|
||||
if (v.longValue() == 0) {
|
||||
return evaluate(cexpr.getNegativeResultExpression(), maxdepth);
|
||||
}
|
||||
|
@ -461,7 +473,7 @@ public class Value implements IValue {
|
|||
try {
|
||||
return ExpressionEvaluator.getNumber(litEx.getValue());
|
||||
} catch (EvalException e) {
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
case IASTLiteralExpression.lk_char_constant:
|
||||
try {
|
||||
|
@ -470,30 +482,39 @@ public class Value implements IValue {
|
|||
return ExpressionEvaluator.getChar(image, 2);
|
||||
return ExpressionEvaluator.getChar(image, 1);
|
||||
} catch (EvalException e) {
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exp instanceof IASTTypeIdExpression) {
|
||||
IASTTypeIdExpression typeIdExp = (IASTTypeIdExpression) exp;
|
||||
ASTTranslationUnit ast = (ASTTranslationUnit) exp.getTranslationUnit();
|
||||
final IType type = ast.createType(((IASTTypeIdExpression) exp).getTypeId());
|
||||
final IType type = ast.createType(typeIdExp.getTypeId());
|
||||
if (type instanceof ICPPUnknownType)
|
||||
return null;
|
||||
return applyUnaryTypeIdOperator(((IASTTypeIdExpression) exp).getOperator(), type, exp);
|
||||
return applyUnaryTypeIdOperator(typeIdExp.getOperator(), type, exp);
|
||||
}
|
||||
|
||||
if (exp instanceof IASTBinaryTypeIdExpression) {
|
||||
|
||||
IASTBinaryTypeIdExpression typeIdExp = (IASTBinaryTypeIdExpression) exp;
|
||||
ASTTranslationUnit ast = (ASTTranslationUnit) exp.getTranslationUnit();
|
||||
IType t1= ast.createType(typeIdExp.getOperand1());
|
||||
IType t2= ast.createType(typeIdExp.getOperand2());
|
||||
if (CPPTemplates.isDependentType(t1) || CPPTemplates.isDependentType(t2))
|
||||
return null;
|
||||
return applyBinaryTypeIdOperator(typeIdExp.getOperator(), t1, t2, exp);
|
||||
}
|
||||
throw UNKNOWN_EX;
|
||||
if (exp instanceof IASTFunctionCallExpression) {
|
||||
return null; // The value will be obtained from the evaluation.
|
||||
}
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a value off a binding.
|
||||
*/
|
||||
private static Long evaluateBinding(IBinding b, int maxdepth) throws UnknownValueException {
|
||||
private static Number evaluateBinding(IBinding b, int maxdepth) {
|
||||
if (b instanceof IType) {
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
if (b instanceof ICPPTemplateNonTypeParameter) {
|
||||
return null;
|
||||
|
@ -515,11 +536,10 @@ public class Value implements IValue {
|
|||
return value.numericalValue();
|
||||
}
|
||||
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
|
||||
private static Long evaluateUnaryExpression(IASTUnaryExpression exp, int maxdepth)
|
||||
throws UnknownValueException {
|
||||
private static Number evaluateUnaryExpression(IASTUnaryExpression exp, int maxdepth) {
|
||||
final int unaryOp= exp.getOperator();
|
||||
|
||||
if (unaryOp == IASTUnaryExpression.op_sizeof) {
|
||||
|
@ -534,21 +554,21 @@ public class Value implements IValue {
|
|||
if (info != null)
|
||||
return info.size;
|
||||
}
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
|
||||
if (unaryOp == IASTUnaryExpression.op_amper || unaryOp == IASTUnaryExpression.op_star ||
|
||||
unaryOp == IASTUnaryExpression.op_sizeofParameterPack) {
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
|
||||
final Long value= evaluate(exp.getOperand(), maxdepth);
|
||||
if (value == null)
|
||||
return null;
|
||||
return applyUnaryOperator(unaryOp, value);
|
||||
final Number value= evaluate(exp.getOperand(), maxdepth);
|
||||
if (value == null || value == VALUE_CANNOT_BE_DETERMINED)
|
||||
return value;
|
||||
return applyUnaryOperator(unaryOp, value.longValue());
|
||||
}
|
||||
|
||||
private static long applyUnaryOperator(final int unaryOp, final long value) throws UnknownValueException {
|
||||
private static Number applyUnaryOperator(final int unaryOp, final long value) {
|
||||
switch (unaryOp) {
|
||||
case IASTUnaryExpression.op_bracketedPrimary:
|
||||
case IASTUnaryExpression.op_plus:
|
||||
|
@ -569,11 +589,10 @@ public class Value implements IValue {
|
|||
case IASTUnaryExpression.op_not:
|
||||
return value == 0 ? 1 : 0;
|
||||
}
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
|
||||
private static Long evaluateBinaryExpression(IASTBinaryExpression exp, int maxdepth)
|
||||
throws UnknownValueException {
|
||||
private static Number evaluateBinaryExpression(IASTBinaryExpression exp, int maxdepth) {
|
||||
final int op= exp.getOperator();
|
||||
switch (op) {
|
||||
case IASTBinaryExpression.op_equals:
|
||||
|
@ -586,28 +605,27 @@ public class Value implements IValue {
|
|||
break;
|
||||
}
|
||||
|
||||
final Long o1= evaluate(exp.getOperand1(), maxdepth);
|
||||
if (o1 == null)
|
||||
return null;
|
||||
final Long o2= evaluate(exp.getOperand2(), maxdepth);
|
||||
if (o2 == null)
|
||||
return null;
|
||||
final Number o1= evaluate(exp.getOperand1(), maxdepth);
|
||||
if (o1 == null || o1 == VALUE_CANNOT_BE_DETERMINED)
|
||||
return o1;
|
||||
final Number o2= evaluate(exp.getOperand2(), maxdepth);
|
||||
if (o2 == null || o2 == VALUE_CANNOT_BE_DETERMINED)
|
||||
return o2;
|
||||
|
||||
return applyBinaryOperator(op, o1, o2);
|
||||
return applyBinaryOperator(op, o1.longValue(), o2.longValue());
|
||||
}
|
||||
|
||||
private static long applyBinaryOperator(final int op, final long v1, final long v2)
|
||||
throws UnknownValueException {
|
||||
private static Number applyBinaryOperator(final int op, final long v1, final long v2) {
|
||||
switch (op) {
|
||||
case IASTBinaryExpression.op_multiply:
|
||||
return v1 * v2;
|
||||
case IASTBinaryExpression.op_divide:
|
||||
if (v2 == 0)
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
return v1 / v2;
|
||||
case IASTBinaryExpression.op_modulo:
|
||||
if (v2 == 0)
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
return v1 % v2;
|
||||
case IASTBinaryExpression.op_plus:
|
||||
return v1 + v2;
|
||||
|
@ -644,7 +662,7 @@ public class Value implements IValue {
|
|||
case IASTBinaryExpression.op_min:
|
||||
return Math.min(v1, v2);
|
||||
}
|
||||
throw UNKNOWN_EX;
|
||||
return VALUE_CANNOT_BE_DETERMINED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,11 +51,7 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC
|
|||
@Override
|
||||
public CASTIdExpression copy(CopyStyle style) {
|
||||
CASTIdExpression copy = new CASTIdExpression(name == null ? null : name.copy(style));
|
||||
copy.setOffsetAndLength(this);
|
||||
if (style == CopyStyle.withLocations) {
|
||||
copy.setCopyLocation(this);
|
||||
}
|
||||
return copy;
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,13 +101,13 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC
|
|||
public IType getExpressionType() {
|
||||
IBinding binding = getName().resolveBinding();
|
||||
if (binding instanceof IVariable) {
|
||||
return ((IVariable)binding).getType();
|
||||
return ((IVariable) binding).getType();
|
||||
}
|
||||
if (binding instanceof IFunction) {
|
||||
return ((IFunction)binding).getType();
|
||||
return ((IFunction) binding).getType();
|
||||
}
|
||||
if (binding instanceof IEnumerator) {
|
||||
return ((IEnumerator)binding).getType();
|
||||
return ((IEnumerator) binding).getType();
|
||||
}
|
||||
if (binding instanceof IProblemBinding) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
|
||||
|
|
|
@ -72,12 +72,8 @@ public class CPPASTAliasDeclaration extends ASTNode implements ICPPASTAliasDecla
|
|||
public ICPPASTAliasDeclaration copy(CopyStyle style) {
|
||||
CPPASTAliasDeclaration copy = new CPPASTAliasDeclaration(
|
||||
aliasName == null ? null : aliasName.copy(style),
|
||||
mappingTypeId == null ? null : mappingTypeId.copy(style));
|
||||
copy.setOffsetAndLength(this);
|
||||
if (style == CopyStyle.withLocations) {
|
||||
copy.setCopyLocation(this);
|
||||
}
|
||||
return copy;
|
||||
mappingTypeId == null ? null : mappingTypeId.copy(style));
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -266,7 +266,7 @@ public class CPPASTFunctionCallExpression extends ASTNode
|
|||
|
||||
if (eval instanceof EvalTypeId) {
|
||||
if (!eval.isTypeDependent()) {
|
||||
IType t= getNestedType(((EvalTypeId) eval).getInputType(), TDEF|CVTYPE|REF);
|
||||
IType t= getNestedType(((EvalTypeId) eval).getInputType(), TDEF | CVTYPE | REF);
|
||||
if (t instanceof ICPPClassType && !(t instanceof ICPPUnknownBinding)) {
|
||||
ICPPClassType cls= (ICPPClassType) t;
|
||||
LookupData data= CPPSemantics.createLookupData(((IASTIdExpression) functionName).getName());
|
||||
|
|
|
@ -27,8 +27,8 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
* Models a function definition without a try-block. If used for a constructor definition it may contain
|
||||
* member initializers.
|
||||
* Models a function definition without a try-block. If used for a constructor definition
|
||||
* it may contain member initializers.
|
||||
*/
|
||||
public class CPPASTFunctionDefinition extends ASTNode
|
||||
implements ICPPASTFunctionDefinition, IASTAmbiguityParent {
|
||||
|
@ -68,16 +68,13 @@ public class CPPASTFunctionDefinition extends ASTNode
|
|||
|
||||
copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style));
|
||||
|
||||
for (ICPPASTConstructorChainInitializer initializer : getMemberInitializers())
|
||||
for (ICPPASTConstructorChainInitializer initializer : getMemberInitializers()) {
|
||||
copy.addMemberInitializer(initializer == null ? null : initializer.copy(style));
|
||||
}
|
||||
|
||||
copy.fDefaulted = fDefaulted;
|
||||
copy.fDeleted = fDeleted;
|
||||
copy.setOffsetAndLength(this);
|
||||
if (style == CopyStyle.withLocations) {
|
||||
copy.setCopyLocation(this);
|
||||
}
|
||||
return copy;
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -48,11 +48,7 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP
|
|||
@Override
|
||||
public CPPASTIdExpression copy(CopyStyle style) {
|
||||
CPPASTIdExpression copy = new CPPASTIdExpression(name == null ? null : name.copy(style));
|
||||
copy.setOffsetAndLength(this);
|
||||
if (style == CopyStyle.withLocations) {
|
||||
copy.setCopyLocation(this);
|
||||
}
|
||||
return copy;
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,7 +90,8 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP
|
|||
|
||||
@Override
|
||||
public int getRoleForName(IASTName n) {
|
||||
if (name == n) return r_reference;
|
||||
if (name == n)
|
||||
return r_reference;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
|
@ -107,12 +104,12 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP
|
|||
public String toString() {
|
||||
return name != null ? name.toString() : "<unnamed>"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
|
||||
return findBindings(n, isPrefix, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation getEvaluation() {
|
||||
if (fEvaluation == null) {
|
||||
|
@ -120,7 +117,7 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP
|
|||
}
|
||||
return fEvaluation;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IType getExpressionType() {
|
||||
IType type= getEvaluation().getTypeOrFunctionSet(this);
|
||||
|
@ -128,12 +125,12 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP
|
|||
IBinding binding= name.resolveBinding();
|
||||
if (binding instanceof IFunction) {
|
||||
return SemanticUtil.mapToAST(((IFunction) binding).getType(), this);
|
||||
}
|
||||
}
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLValue() {
|
||||
return getValueCategory() == LVALUE;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Mike Kucera (IBM) - Initial API and implementation
|
||||
* Mike Kucera (IBM) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
|||
public class CPPASTImplicitName extends CPPASTName implements IASTImplicitName {
|
||||
private boolean alternate;
|
||||
private boolean isOperator;
|
||||
private boolean isDefinition= false;
|
||||
private boolean isDefinition;
|
||||
|
||||
public CPPASTImplicitName(char[] name, IASTNode parent) {
|
||||
super(name);
|
||||
|
|
|
@ -263,7 +263,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
|||
if (image.length > 1 && image[0] == 'L')
|
||||
return Value.create(ExpressionEvaluator.getChar(image, 2));
|
||||
return Value.create(ExpressionEvaluator.getChar(image, 1));
|
||||
} catch (EvalException e1) {
|
||||
} catch (EvalException e) {
|
||||
return Value.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
|||
private IValue createIntValue() {
|
||||
try {
|
||||
return Value.create(ExpressionEvaluator.getNumber(getValue()));
|
||||
} catch (EvalException e1) {
|
||||
} catch (EvalException e) {
|
||||
return Value.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Mike Kucera (IBM)
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Mike Kucera (IBM)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -30,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IArrayType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
|
@ -46,7 +48,7 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
|
|||
private IASTInitializerClause[] placement;
|
||||
private IASTTypeId typeId;
|
||||
private IASTInitializer initializer;
|
||||
private IASTImplicitName[] implicitNames = null;
|
||||
private IASTImplicitName[] implicitNames;
|
||||
private boolean isGlobal;
|
||||
private boolean isNewTypeId;
|
||||
|
||||
|
@ -163,15 +165,35 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
|
|||
@Override
|
||||
public IASTImplicitName[] getImplicitNames() {
|
||||
if (implicitNames == null) {
|
||||
CPPASTImplicitName operatorName = null;
|
||||
ICPPFunction operatorFunction = CPPSemantics.findOverloadedOperator(this);
|
||||
if (operatorFunction == null || operatorFunction instanceof CPPImplicitFunction) {
|
||||
implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
|
||||
} else {
|
||||
CPPASTImplicitName operatorName = new CPPASTImplicitName(operatorFunction.getNameCharArray(), this);
|
||||
if (operatorFunction != null && !(operatorFunction instanceof CPPImplicitFunction)) {
|
||||
operatorName = new CPPASTImplicitName(operatorFunction.getNameCharArray(), this);
|
||||
operatorName.setOperator(true);
|
||||
operatorName.setBinding(operatorFunction);
|
||||
operatorName.setOffsetAndLength(getOffset(), 3);
|
||||
implicitNames = new IASTImplicitName[] { operatorName };
|
||||
}
|
||||
|
||||
CPPASTImplicitName constructorName = null;
|
||||
ICPPConstructor constructor = CPPSemantics.findImplicitlyCalledConstructor(this);
|
||||
if (constructor != null) {
|
||||
constructorName = new CPPASTImplicitName(constructor.getNameCharArray(), this);
|
||||
constructorName.setBinding(constructor);
|
||||
constructorName.setOffsetAndLength((ASTNode) getTypeId());
|
||||
}
|
||||
|
||||
if (operatorName != null) {
|
||||
if (constructorName != null) {
|
||||
implicitNames = new IASTImplicitName[] { operatorName, constructorName };
|
||||
} else {
|
||||
implicitNames = new IASTImplicitName[] { operatorName };
|
||||
}
|
||||
} else {
|
||||
if (constructorName != null) {
|
||||
implicitNames = new IASTImplicitName[] { constructorName };
|
||||
} else {
|
||||
implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Thomas Corbat (IFS) - Initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -28,7 +29,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
public class CPPAliasTemplate extends PlatformObject implements ICPPAliasTemplate {
|
||||
public class CPPAliasTemplate extends PlatformObject
|
||||
implements ICPPAliasTemplate, ICPPTemplateParameterOwner {
|
||||
private final IASTName aliasName;
|
||||
private final IType aliasedType;
|
||||
private ICPPTemplateParameter[] templateParameters;
|
||||
|
@ -128,4 +130,16 @@ public class CPPAliasTemplate extends PlatformObject implements ICPPAliasTemplat
|
|||
public String toString() {
|
||||
return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) {
|
||||
int pos= templateParameter.getParameterPosition();
|
||||
|
||||
ICPPASTTemplateParameter[] params = CPPTemplates.getTemplateDeclaration(aliasName).getTemplateParameters();
|
||||
if (pos < params.length) {
|
||||
final IASTName oName = CPPTemplates.getTemplateParameterName(params[pos]);
|
||||
return oName.resolvePreBinding();
|
||||
}
|
||||
return templateParameter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Thomas Corbat (IFS) - Initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -22,21 +23,22 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
public class CPPAliasTemplateInstance extends PlatformObject
|
||||
implements ICPPAliasTemplateInstance, ISerializableType {
|
||||
implements ICPPAliasTemplateInstance, ITypeContainer, ISerializableType {
|
||||
private final char[] name;
|
||||
private final IType aliasedType;
|
||||
private final ICPPAliasTemplate aliasTemplate;
|
||||
private IType aliasedType;
|
||||
|
||||
public CPPAliasTemplateInstance(char[] name, IType aliasedType, ICPPAliasTemplate aliasTemplate) {
|
||||
public CPPAliasTemplateInstance(char[] name, ICPPAliasTemplate aliasTemplate, IType aliasedType) {
|
||||
this.name = name;
|
||||
this.aliasedType = aliasedType;
|
||||
this.aliasTemplate = aliasTemplate;
|
||||
this.aliasedType = aliasedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,6 +61,11 @@ public class CPPAliasTemplateInstance extends PlatformObject
|
|||
return aliasedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(IType type) {
|
||||
aliasedType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
try {
|
||||
|
@ -115,7 +122,7 @@ public class CPPAliasTemplateInstance extends PlatformObject
|
|||
char[] name = buffer.getCharArray();
|
||||
IType unmarshalledAliasedTypeInstance = buffer.unmarshalType();
|
||||
ICPPAliasTemplate unmarshalledAlias = (ICPPAliasTemplate)buffer.unmarshalBinding();
|
||||
return new CPPAliasTemplateInstance(name, unmarshalledAliasedTypeInstance, unmarshalledAlias);
|
||||
return new CPPAliasTemplateInstance(name, unmarshalledAlias, unmarshalledAliasedTypeInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class CPPBuiltinParameter extends PlatformObject implements ICPPParameter
|
|||
return result;
|
||||
}
|
||||
|
||||
private IType type= null;
|
||||
private IType type;
|
||||
|
||||
public CPPBuiltinParameter(IType type) {
|
||||
this.type = type;
|
||||
|
|
|
@ -135,6 +135,11 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
public boolean isFinal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstexpr() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private ICPPClassSpecializationScope specScope;
|
||||
|
|
|
@ -107,11 +107,11 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
|
|||
|
||||
ICPPParameter[] params = new ICPPParameter[parameterTypes.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
params[i]= new CPPParameter(parameterTypes[i], 0);
|
||||
params[i]= new CPPParameter(parameterTypes[i], i);
|
||||
}
|
||||
m= new CPPImplicitMethod(scope, OverloadableOperator.PAREN.toCharArray(), ft, params) {
|
||||
@Override
|
||||
public boolean isImplicit() {return false;}
|
||||
public boolean isImplicit() { return false; }
|
||||
};
|
||||
result[4]= m;
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
|
|||
IASTStatement[] stmts = body.getStatements();
|
||||
if (stmts.length > 0) {
|
||||
// Gnu extension allows to deduce return type in complex compound statements
|
||||
IASTStatement stmt= stmts[stmts.length-1];
|
||||
IASTStatement stmt= stmts[stmts.length - 1];
|
||||
if (stmt instanceof IASTReturnStatement) {
|
||||
IASTReturnStatement rtstmt= (IASTReturnStatement) stmt;
|
||||
IASTExpression expr= rtstmt.getReturnValue();
|
||||
|
|
|
@ -19,5 +19,4 @@ public class CPPConstructor extends CPPMethod implements ICPPConstructor {
|
|||
public CPPConstructor(ICPPASTFunctionDeclarator declarator) {
|
||||
super(declarator);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -25,7 +26,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
|||
* Represents a reference to a (member) function (instance), which cannot be resolved because
|
||||
* an argument depends on a template parameter. A compiler would resolve it during instantiation.
|
||||
*/
|
||||
public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction {
|
||||
public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction, ICPPComputableFunction {
|
||||
private static final ICPPFunctionType FUNCTION_TYPE=
|
||||
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
|
||||
|
||||
|
@ -69,6 +70,11 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstexpr() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getFunctionScope() {
|
||||
return asScope();
|
||||
|
@ -128,4 +134,9 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti
|
|||
public IBinding getOwner() {
|
||||
return fOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation getReturnExpression() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,15 +18,19 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
|
|||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -38,6 +42,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
|
@ -52,6 +57,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
|
@ -230,17 +236,8 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
IASTName n = getASTName();
|
||||
IScope scope = CPPVisitor.getContainingScope(n);
|
||||
if (scope instanceof ICPPClassScope) {
|
||||
ICPPASTDeclSpecifier declSpec = null;
|
||||
if (definition != null) {
|
||||
IASTNode node = ASTQueries.findOutermostDeclarator(definition).getParent();
|
||||
IASTFunctionDefinition def = (IASTFunctionDefinition) node;
|
||||
declSpec = (ICPPASTDeclSpecifier) def.getDeclSpecifier();
|
||||
} else {
|
||||
IASTNode node = ASTQueries.findOutermostDeclarator(declarations[0]).getParent();
|
||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration)node;
|
||||
declSpec = (ICPPASTDeclSpecifier) decl.getDeclSpecifier();
|
||||
}
|
||||
if (declSpec.isFriend()) {
|
||||
ICPPASTDeclSpecifier declSpec = getDeclSpecifier();
|
||||
if (declSpec != null && declSpec.isFriend()) {
|
||||
try {
|
||||
while (scope instanceof ICPPClassScope) {
|
||||
scope = scope.getParent();
|
||||
|
@ -252,6 +249,19 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
return scope;
|
||||
}
|
||||
|
||||
private ICPPASTDeclSpecifier getDeclSpecifier() {
|
||||
if (definition != null) {
|
||||
IASTNode node = ASTQueries.findOutermostDeclarator(definition).getParent();
|
||||
IASTFunctionDefinition def = (IASTFunctionDefinition) node;
|
||||
return (ICPPASTDeclSpecifier) def.getDeclSpecifier();
|
||||
} else if (declarations != null && declarations.length != 0) {
|
||||
IASTNode node = ASTQueries.findOutermostDeclarator(declarations[0]).getParent();
|
||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) node;
|
||||
return (ICPPASTDeclSpecifier) decl.getDeclSpecifier();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPFunctionType getType() {
|
||||
if (type == null) {
|
||||
|
@ -420,9 +430,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
|
||||
IASTDeclSpecifier declSpec = null;
|
||||
if (parent instanceof IASTSimpleDeclaration) {
|
||||
declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier();
|
||||
declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
|
||||
} else if (parent instanceof IASTFunctionDefinition) {
|
||||
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
|
||||
declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier();
|
||||
}
|
||||
if (declSpec != null && declSpec.getStorageClass() == storage) {
|
||||
return true;
|
||||
|
@ -437,19 +447,14 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return isDeletedDefinition(getDefinition());
|
||||
}
|
||||
|
||||
public static boolean isDeletedDefinition(IASTNode def) {
|
||||
static ICPPASTFunctionDefinition getFunctionDefinition(IASTNode def) {
|
||||
while (def != null && !(def instanceof IASTDeclaration)) {
|
||||
def= def.getParent();
|
||||
}
|
||||
if (def instanceof ICPPASTFunctionDefinition) {
|
||||
return ((ICPPASTFunctionDefinition) def).isDeleted();
|
||||
return (ICPPASTFunctionDefinition) def;
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -511,6 +516,26 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
return hasStorageClass(this, IASTDeclSpecifier.sc_auto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstexpr() {
|
||||
ICPPASTDeclSpecifier declSpec = getDeclSpecifier();
|
||||
if (declSpec == null)
|
||||
return false;
|
||||
return declSpec.isConstexpr();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return isDeletedDefinition(getDefinition());
|
||||
}
|
||||
|
||||
static boolean isDeletedDefinition(IASTNode def) {
|
||||
ICPPASTFunctionDefinition functionDefinition = getFunctionDefinition(def);
|
||||
if (functionDefinition != null)
|
||||
return functionDefinition.isDeleted();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return hasStorageClass(this, IASTDeclSpecifier.sc_register);
|
||||
|
@ -608,4 +633,46 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
ICPPASTFunctionDeclarator dtor = getPreferredDtor();
|
||||
return dtor != null && AttributeUtil.hasNoreturnAttribute(dtor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation getReturnExpression() {
|
||||
if (!isConstexpr())
|
||||
return null;
|
||||
if (definition == null)
|
||||
return EvalFixed.INCOMPLETE;
|
||||
|
||||
IASTNode node = ASTQueries.findOutermostDeclarator(definition).getParent();
|
||||
return getReturnExpression((IASTFunctionDefinition) node);
|
||||
}
|
||||
|
||||
static ICPPEvaluation getReturnExpression(IASTFunctionDefinition functionDefinition) {
|
||||
IASTReturnStatement returnStatement = null;
|
||||
IASTStatement body = functionDefinition.getBody();
|
||||
if (body instanceof IASTReturnStatement) {
|
||||
returnStatement = (IASTReturnStatement) body;
|
||||
} else if (body instanceof IASTCompoundStatement) {
|
||||
for (IASTStatement statement : ((IASTCompoundStatement) body).getStatements()) {
|
||||
if (statement instanceof IASTReturnStatement) {
|
||||
if (returnStatement != null)
|
||||
return EvalFixed.INCOMPLETE;
|
||||
returnStatement = (IASTReturnStatement) statement;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (returnStatement == null)
|
||||
return EvalFixed.INCOMPLETE; // constexpr constructors are not supported yet.
|
||||
|
||||
IASTInitializerClause returnExpression = returnStatement.getReturnArgument();
|
||||
if (returnExpression instanceof ICPPASTInitializerClause)
|
||||
return ((ICPPASTInitializerClause) returnExpression).getEvaluation();
|
||||
|
||||
return EvalFixed.INCOMPLETE;
|
||||
}
|
||||
|
||||
public static ICPPEvaluation getReturnExpression(ICPPFunction function) {
|
||||
if (function instanceof ICPPComputableFunction) {
|
||||
return ((ICPPComputableFunction) function).getReturnExpression();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
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 {
|
||||
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);
|
||||
fArguments = args;
|
||||
}
|
||||
|
@ -73,11 +74,11 @@ public class CPPFunctionInstance extends CPPFunctionSpecialization implements IC
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if( (obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)){
|
||||
final ICPPTemplateInstance inst = (ICPPTemplateInstance)obj;
|
||||
ICPPFunctionType ct1= ((ICPPFunction)getSpecializedBinding()).getType();
|
||||
ICPPFunctionType ct2= ((ICPPFunction)inst.getTemplateDefinition()).getType();
|
||||
if(!ct1.isSameType(ct2))
|
||||
if ((obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)) {
|
||||
final ICPPTemplateInstance inst = (ICPPTemplateInstance) obj;
|
||||
ICPPFunctionType ct1= ((ICPPFunction) getSpecializedBinding()).getType();
|
||||
ICPPFunctionType ct2= ((ICPPFunction) inst.getTemplateDefinition()).getType();
|
||||
if (!ct1.isSameType(ct2))
|
||||
return false;
|
||||
|
||||
return CPPTemplates.haveSameArguments(this, inst);
|
||||
|
|
|
@ -24,7 +24,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
|
@ -43,7 +45,8 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
private ICPPParameter[] fParams;
|
||||
private final IType[] fExceptionSpecs;
|
||||
|
||||
public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||
public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap,
|
||||
ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||
super(orig, owner, argMap);
|
||||
fType= type;
|
||||
fExceptionSpecs= exceptionSpecs;
|
||||
|
@ -103,19 +106,6 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
IASTNode def = getDefinition();
|
||||
if (def != null)
|
||||
return CPPFunction.isDeletedDefinition(def);
|
||||
|
||||
IBinding f = getSpecializedBinding();
|
||||
if (f instanceof ICPPFunction) {
|
||||
return ((ICPPFunction) f).isDeleted();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
if (getDefinition() != null) {
|
||||
|
@ -168,6 +158,33 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_auto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstexpr() {
|
||||
IASTNode def = getDefinition();
|
||||
if (def != null) {
|
||||
ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(def);
|
||||
return ((ICPPASTDeclSpecifier) functionDefinition.getDeclSpecifier()).isConstexpr();
|
||||
}
|
||||
IBinding f = getSpecializedBinding();
|
||||
if (f instanceof ICPPFunction) {
|
||||
return ((ICPPFunction) f).isConstexpr();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
IASTNode def = getDefinition();
|
||||
if (def != null)
|
||||
return CPPFunction.isDeletedDefinition(def);
|
||||
|
||||
IBinding f = getSpecializedBinding();
|
||||
if (f instanceof ICPPFunction) {
|
||||
return ((ICPPFunction) f).isDeleted();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
ICPPFunction f = (ICPPFunction) getSpecializedBinding();
|
||||
|
@ -314,4 +331,21 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
public IType[] getExceptionSpecification() {
|
||||
return fExceptionSpecs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation getReturnExpression() {
|
||||
if (!isConstexpr())
|
||||
return null;
|
||||
|
||||
IASTNode def = getDefinition();
|
||||
if (def != null) {
|
||||
ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(def);
|
||||
return CPPFunction.getReturnExpression(functionDefinition);
|
||||
}
|
||||
IBinding f = getSpecializedBinding();
|
||||
if (f instanceof ICPPComputableFunction) {
|
||||
return ((ICPPComputableFunction) f).getReturnExpression();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
|
@ -41,6 +42,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
||||
|
||||
/**
|
||||
* Implementation of function templates
|
||||
|
@ -183,10 +185,10 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
|||
|
||||
protected ICPPASTDeclSpecifier getDeclSpecifier(IASTDeclaration decl) {
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
return (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier();
|
||||
return (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
||||
}
|
||||
if (decl instanceof IASTFunctionDefinition) {
|
||||
return (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier();
|
||||
return (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) decl).getDeclSpecifier();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -316,16 +318,24 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
|||
return hasStorageClass(IASTDeclSpecifier.sc_extern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return CPPFunction.isDeletedDefinition(getDefinition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstexpr() {
|
||||
ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(getDefinition());
|
||||
if (functionDefinition == null)
|
||||
return false;
|
||||
return ((ICPPASTDeclSpecifier) functionDefinition.getDeclSpecifier()).isConstexpr();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return CPPFunction.isDeletedDefinition(getDefinition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
||||
|
@ -394,4 +404,14 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation getReturnExpression() {
|
||||
if (!isConstexpr())
|
||||
return null;
|
||||
ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(getDefinition());
|
||||
if (functionDefinition == null)
|
||||
return EvalFixed.INCOMPLETE;
|
||||
return CPPFunction.getReturnExpression(functionDefinition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
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
|
||||
implements ICPPFunctionTemplate, ICPPInternalTemplate {
|
||||
|
||||
private ObjectMap instances = null;
|
||||
private ObjectMap instances;
|
||||
|
||||
public CPPFunctionTemplateSpecialization(ICPPFunction original, ICPPClassType owner, ICPPTemplateParameterMap argumentMap, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||
super(original, owner, argumentMap, type, exceptionSpecs);
|
||||
|
|
|
@ -31,8 +31,8 @@ import org.eclipse.core.runtime.PlatformObject;
|
|||
* Binding for a c++ function parameter
|
||||
*/
|
||||
public class CPPLambdaExpressionParameter extends PlatformObject implements ICPPParameter {
|
||||
private IType fType = null;
|
||||
private IASTName fDeclaration = null;
|
||||
private IType fType;
|
||||
private IASTName fDeclaration;
|
||||
|
||||
public CPPLambdaExpressionParameter(IASTName name) {
|
||||
fDeclaration = name;
|
||||
|
@ -77,14 +77,17 @@ public class CPPLambdaExpressionParameter extends PlatformObject implements ICPP
|
|||
public boolean isStatic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQualifiedName() {
|
||||
return new String[] { getName() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return new char[][] { getNameCharArray() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGloballyQualified() {
|
||||
return false;
|
||||
|
|
|
@ -23,16 +23,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
|
||||
*/
|
||||
@Override
|
||||
public int getVisibility() {
|
||||
return ((ICPPMethod)getTemplateDefinition()).getVisibility();
|
||||
return ((ICPPMethod) getTemplateDefinition()).getVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,20 +38,14 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
|
|||
return (ICPPClassType) getOwner();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
|
||||
*/
|
||||
@Override
|
||||
public boolean isVirtual() {
|
||||
return ((ICPPMethod)getTemplateDefinition()).isVirtual();
|
||||
return ((ICPPMethod) getTemplateDefinition()).isVirtual();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPureVirtual() {
|
||||
return ((ICPPMethod)getTemplateDefinition()).isPureVirtual();
|
||||
return ((ICPPMethod) getTemplateDefinition()).isPureVirtual();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,9 +53,6 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
|
|||
return ((ICPPMethod) getTemplateDefinition()).isExplicit();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
|
||||
*/
|
||||
@Override
|
||||
public boolean isDestructor() {
|
||||
char[] name = getNameCharArray();
|
||||
|
@ -80,11 +69,11 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
|
|||
|
||||
@Override
|
||||
public boolean isOverride() {
|
||||
return ((ICPPMethod)getTemplateDefinition()).isOverride();
|
||||
return ((ICPPMethod) getTemplateDefinition()).isOverride();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return ((ICPPMethod)getTemplateDefinition()).isFinal();
|
||||
return ((ICPPMethod) getTemplateDefinition()).isFinal();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,8 +255,8 @@ public abstract class CPPTemplateParameter extends PlatformObject
|
|||
return current;
|
||||
|
||||
ICPPTemplateDefinition template= CPPTemplates.getContainingTemplate(getASTTemplateParameter());
|
||||
if (template instanceof ICPPInternalTemplate) {
|
||||
return ((ICPPInternalTemplate) template).resolveTemplateParameter(this);
|
||||
if (template instanceof ICPPTemplateParameterOwner) {
|
||||
return ((ICPPTemplateParameterOwner) template).resolveTemplateParameter(this);
|
||||
}
|
||||
|
||||
// problem finding the containing template
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
|
@ -28,7 +28,8 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType
|
|||
|
||||
private IType fType;
|
||||
|
||||
public CPPTypedefSpecialization(IBinding specialized, ICPPClassType owner, ICPPTemplateParameterMap tpmap, IType type) {
|
||||
public CPPTypedefSpecialization(IBinding specialized, ICPPClassType owner,
|
||||
ICPPTemplateParameterMap tpmap, IType type) {
|
||||
super(specialized, owner, tpmap);
|
||||
fType= type;
|
||||
}
|
||||
|
@ -38,23 +39,17 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType
|
|||
return fType;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
IType t = null;
|
||||
try {
|
||||
t = (IType) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// not going to happen
|
||||
// Not going to happen.
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
||||
*/
|
||||
@Override
|
||||
public boolean isSameType(IType o) {
|
||||
if (o == this)
|
||||
|
|
|
@ -33,6 +33,7 @@ public class CPPUnknownMemberClass extends CPPUnknownMember implements ICPPUnkno
|
|||
public static CPPUnknownMemberClass createUnnamedInstance() {
|
||||
return new CPPUnknownMemberClass(null, CharArrayUtils.EMPTY);
|
||||
}
|
||||
|
||||
public CPPUnknownMemberClass(IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
}
|
||||
|
|
|
@ -156,4 +156,9 @@ public class CPPUnknownMethod extends CPPUnknownMember implements ICPPMethod {
|
|||
public boolean isFinal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstexpr() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
/**
|
||||
* Represents a function the return value of which may potentially be calculated at parsing time.
|
||||
*/
|
||||
public interface ICPPComputableFunction {
|
||||
/**
|
||||
* For a constexpr function returns the return statement expression. Otherwise returns
|
||||
* {@code null}.
|
||||
*/
|
||||
public ICPPEvaluation getReturnExpression();
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -17,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IValue;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionParameterMap;
|
||||
|
||||
/**
|
||||
* Assists in evaluating expressions.
|
||||
|
@ -70,6 +72,17 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
|||
ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point);
|
||||
|
||||
/**
|
||||
* Computes the evaluation produced by substituting function parameters by their values.
|
||||
*
|
||||
* @param parameterMap maps function parameters to their values
|
||||
* @param maxdepth allowed recursion depth
|
||||
* @param point determines the scope for name lookups
|
||||
* @return the computed evaluation
|
||||
*/
|
||||
ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, int maxdepth,
|
||||
IASTNode point);
|
||||
|
||||
/**
|
||||
* Determines size of the template parameter pack.
|
||||
*
|
||||
|
|
|
@ -15,12 +15,10 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
|
||||
|
||||
/**
|
||||
* Caches instances per template, the template definitions need to implement this interface
|
||||
*/
|
||||
public interface ICPPInstanceCache {
|
||||
|
||||
/**
|
||||
* Attempts to cache an instance with this template
|
||||
*/
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -17,8 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
/**
|
||||
* Interface for ast-internal implementations of function bindings.
|
||||
*/
|
||||
public interface ICPPInternalFunction extends ICPPInternalBinding {
|
||||
|
||||
public interface ICPPInternalFunction extends ICPPInternalBinding, ICPPComputableFunction {
|
||||
/**
|
||||
* Called to resolve the parameter in the second phase.
|
||||
*/
|
||||
|
|
|
@ -1,23 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for templates from the ast.
|
||||
* Interface for templates from the AST.
|
||||
*/
|
||||
public interface ICPPInternalTemplate extends ICPPInternalBinding, ICPPInstanceCache {
|
||||
|
||||
IBinding resolveTemplateParameter(ICPPTemplateParameter param);
|
||||
public interface ICPPInternalTemplate
|
||||
extends ICPPTemplateParameterOwner, ICPPInternalBinding, ICPPInstanceCache {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
||||
/**
|
||||
* Interface for templates from the AST.
|
||||
*/
|
||||
public interface ICPPTemplateParameterOwner {
|
||||
|
||||
IBinding resolveTemplateParameter(ICPPTemplateParameter param);
|
||||
}
|
|
@ -72,6 +72,11 @@ class AutoTypeResolver implements ICPPFunctionTemplate {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstexpr() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
|
||||
/**
|
||||
* Maps function parameter positions to values.
|
||||
*/
|
||||
public class CPPFunctionParameterMap {
|
||||
public static final CPPFunctionParameterMap EMPTY = new CPPFunctionParameterMap(0);
|
||||
|
||||
private ObjectMap fMap;
|
||||
|
||||
/**
|
||||
* Constructs an empty parameter map.
|
||||
*/
|
||||
public CPPFunctionParameterMap(int initialSize) {
|
||||
fMap= new ObjectMap(initialSize);
|
||||
}
|
||||
|
||||
public CPPFunctionParameterMap(CPPFunctionParameterMap other) {
|
||||
fMap= (ObjectMap) other.fMap.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the map contains the given parameter
|
||||
*/
|
||||
public boolean contains(int parameterPosition) {
|
||||
return fMap.containsKey(parameterPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the mapping.
|
||||
*/
|
||||
public void put(int parameterPosition, ICPPEvaluation value) {
|
||||
fMap.put(parameterPosition, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the mapping.
|
||||
*/
|
||||
public void put(int parameterPosition, ICPPEvaluation[] packExpansion) {
|
||||
fMap.put(parameterPosition, packExpansion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for the given parameter.
|
||||
*/
|
||||
public ICPPEvaluation getArgument(int parameterPosition) {
|
||||
final Object object = fMap.get(parameterPosition);
|
||||
if (object instanceof ICPPEvaluation) {
|
||||
return (ICPPEvaluation) object;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the values for the given function parameter pack.
|
||||
*/
|
||||
public ICPPEvaluation[] getPackExpansion(int parameterPosition) {
|
||||
final Object object = fMap.get(parameterPosition);
|
||||
if (object instanceof ICPPEvaluation[]) {
|
||||
return (ICPPEvaluation[]) object;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the argument at the given position
|
||||
*/
|
||||
public ICPPEvaluation getArgument(int parameterPosition, int packOffset) {
|
||||
final Object object = fMap.get(parameterPosition);
|
||||
if (object instanceof ICPPEvaluation)
|
||||
return (ICPPEvaluation) object;
|
||||
if (object instanceof ICPPEvaluation[]) {
|
||||
ICPPEvaluation[] args = (ICPPEvaluation[]) object;
|
||||
if (packOffset < args.length && packOffset >= 0)
|
||||
return args[packOffset];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts all mappings from the supplied map into this map.
|
||||
*/
|
||||
public void putAll(CPPFunctionParameterMap map) {
|
||||
final ObjectMap otherMap= map.fMap;
|
||||
for (int i = 0; i < otherMap.size(); i++) {
|
||||
fMap.put(otherMap.keyAt(i), otherMap.getAt(i));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -241,7 +241,7 @@ public class CPPSemantics {
|
|||
|
||||
private static final char[] CALL_FUNCTION = "call-function".toCharArray(); //$NON-NLS-1$
|
||||
private static final ICPPEvaluation[] NO_INITCLAUSE_EVALUATION = {};
|
||||
|
||||
|
||||
// Set to true for debugging.
|
||||
public static boolean traceBindingResolution = false;
|
||||
public static int traceIndent= 0;
|
||||
|
@ -268,7 +268,7 @@ public class CPPSemantics {
|
|||
lookup(data, null);
|
||||
|
||||
// Perform argument dependent lookup
|
||||
if (data.checkAssociatedScopes() && !data.hasTypeOrMemberFunctionResult()) {
|
||||
if (data.checkAssociatedScopes() && !data.hasTypeOrMemberFunctionOrVariableResult()) {
|
||||
doKoenigLookup(data);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
|
@ -308,7 +308,7 @@ public class CPPSemantics {
|
|||
final IASTName lookupName = data.getLookupName();
|
||||
if (lookupName == null)
|
||||
return binding;
|
||||
|
||||
|
||||
IASTNode lookupPoint = data.getLookupPoint();
|
||||
|
||||
if (binding == null && data.checkClassContainingFriend()) {
|
||||
|
@ -904,7 +904,7 @@ public class CPPSemantics {
|
|||
IASTName lookupName= data.getLookupName();
|
||||
if (lookupName == null)
|
||||
return;
|
||||
|
||||
|
||||
nextScope= getLookupScope(lookupName);
|
||||
|
||||
if (nextScope instanceof ICPPTemplateScope) {
|
||||
|
@ -1087,7 +1087,7 @@ public class CPPSemantics {
|
|||
IBinding[] typedefs = ld2.getFoundBindings();
|
||||
if (typedefs.length < 1 || !(typedefs[0] instanceof ITypedef))
|
||||
return false;
|
||||
|
||||
|
||||
IType t= SemanticUtil.getNestedType((ITypedef) typedefs[0], TDEF);
|
||||
if (t instanceof ICPPUnknownBinding || t instanceof ISemanticProblem ||
|
||||
!(t instanceof ICPPClassType)) {
|
||||
|
@ -1224,7 +1224,7 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return expandUsingDeclarationsAndRemoveObjects(bindings, data);
|
||||
}
|
||||
|
||||
|
@ -1489,7 +1489,7 @@ public class CPPSemantics {
|
|||
} else {
|
||||
populateCache(scope, item);
|
||||
}
|
||||
|
||||
|
||||
if (nodes != null && ++idx < nodes.length) {
|
||||
item = nodes[idx];
|
||||
} else {
|
||||
|
@ -1531,7 +1531,7 @@ public class CPPSemantics {
|
|||
idx = nodeIdxStack[nodeStackPos--];
|
||||
if (++idx >= nodes.length)
|
||||
continue;
|
||||
|
||||
|
||||
item = nodes[idx];
|
||||
}
|
||||
break;
|
||||
|
@ -1764,16 +1764,16 @@ public class CPPSemantics {
|
|||
// Bug 238180
|
||||
if (candidate instanceof ICPPClassTemplatePartialSpecialization)
|
||||
return null;
|
||||
|
||||
|
||||
// Specialization is selected during instantiation
|
||||
if (candidate instanceof ICPPTemplateInstance)
|
||||
candidate= ((ICPPTemplateInstance) candidate).getSpecializedBinding();
|
||||
|
||||
|
||||
if (!(candidate instanceof ICPPFunctionTemplate))
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LookupData data = createLookupData(name);
|
||||
data.foundItems = bindings;
|
||||
try {
|
||||
|
@ -1781,7 +1781,7 @@ public class CPPSemantics {
|
|||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
}
|
||||
//
|
||||
//
|
||||
// IBinding[] result = null;
|
||||
// for (Object binding : bindings) {
|
||||
// if (binding instanceof IASTName) {
|
||||
|
@ -1796,13 +1796,13 @@ public class CPPSemantics {
|
|||
public static boolean declaredBefore(Object obj, IASTNode node, boolean indexBased) {
|
||||
if (node == null)
|
||||
return true;
|
||||
|
||||
|
||||
final int pointOfRef= ((ASTNode) node).getOffset();
|
||||
ASTNode nd = null;
|
||||
if (obj instanceof ICPPSpecialization) {
|
||||
obj = ((ICPPSpecialization) obj).getSpecializedBinding();
|
||||
}
|
||||
|
||||
|
||||
int pointOfDecl= -1;
|
||||
if (obj instanceof ICPPInternalBinding) {
|
||||
ICPPInternalBinding cpp = (ICPPInternalBinding) obj;
|
||||
|
@ -1838,7 +1838,7 @@ public class CPPSemantics {
|
|||
pointOfDecl= ((ICPPUsingDirective) obj).getPointOfDeclaration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (pointOfDecl < 0 && nd != null) {
|
||||
ASTNodeProperty prop = nd.getPropertyInParent();
|
||||
if (prop == IASTDeclarator.DECLARATOR_NAME || nd instanceof IASTDeclarator) {
|
||||
|
@ -1903,13 +1903,13 @@ public class CPPSemantics {
|
|||
final IASTName lookupName = data.getLookupName();
|
||||
IASTNode lookupPoint = data.getLookupPoint();
|
||||
final boolean indexBased= data.getIndex() != null;
|
||||
final boolean checkWholeClass= lookupName == null || LookupData.checkWholeClassScope(lookupName);
|
||||
final boolean checkWholeClass= lookupName == null || LookupData.checkWholeClassScope(lookupName);
|
||||
@SuppressWarnings("unchecked")
|
||||
ObjectSet<ICPPFunction> fns= ObjectSet.EMPTY_SET;
|
||||
IBinding type = null;
|
||||
IBinding obj = null;
|
||||
IBinding temp = null;
|
||||
|
||||
|
||||
final CPPASTTranslationUnit tu = data.getTranslationUnit();
|
||||
Object[] items = (Object[]) data.foundItems;
|
||||
for (int i = 0; i < items.length && items[i] != null; i++) {
|
||||
|
@ -2059,7 +2059,7 @@ public class CPPSemantics {
|
|||
if (type != null && overrulesByRelevance(data, type, fnArray)) {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
if (obj != null) {
|
||||
int cmp= compareByRelevance(data, obj, fnArray);
|
||||
if (cmp == 0) {
|
||||
|
@ -2072,7 +2072,7 @@ public class CPPSemantics {
|
|||
}
|
||||
return resolveFunction(data, fnArray, true);
|
||||
}
|
||||
|
||||
|
||||
if (obj != null) {
|
||||
return obj;
|
||||
}
|
||||
|
@ -2342,9 +2342,9 @@ public class CPPSemantics {
|
|||
if (fns == null || fns.length == 0 || fns[0] == null)
|
||||
return null;
|
||||
fns= ArrayUtil.trim(fns);
|
||||
|
||||
|
||||
sortAstBeforeIndex(fns);
|
||||
|
||||
|
||||
if (data.forUsingDeclaration)
|
||||
return new CPPUsingDeclaration(lookupName, fns);
|
||||
|
||||
|
@ -2355,7 +2355,7 @@ public class CPPSemantics {
|
|||
if (data.forDeclaration() != null) {
|
||||
return resolveFunctionDeclaration(data, fns);
|
||||
}
|
||||
|
||||
|
||||
// No arguments to resolve function
|
||||
final IASTNode lookupPoint = data.getLookupPoint();
|
||||
if (!data.hasFunctionArguments()) {
|
||||
|
@ -2365,9 +2365,9 @@ public class CPPSemantics {
|
|||
// Reduce our set of candidate functions to only those who have the right number of parameters
|
||||
final IType[] argTypes = data.getFunctionArgumentTypes();
|
||||
ICPPFunction[] tmp= selectByArgumentCount(data, fns);
|
||||
tmp= CPPTemplates.instantiateForFunctionCall(tmp, data.fTemplateArguments,
|
||||
tmp= CPPTemplates.instantiateForFunctionCall(tmp, data.fTemplateArguments,
|
||||
Arrays.asList(argTypes),
|
||||
Arrays.asList(data.getFunctionArgumentValueCategories()),
|
||||
Arrays.asList(data.getFunctionArgumentValueCategories()),
|
||||
data.argsContainImpliedObject, lookupPoint);
|
||||
if (tmp.length == 0 || tmp[0] == null) {
|
||||
return new ProblemBinding(lookupName, lookupPoint, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, fns);
|
||||
|
@ -2522,7 +2522,7 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
|
||||
if (result instanceof ICPPFunctionTemplate)
|
||||
if (result instanceof ICPPFunctionTemplate)
|
||||
return CPPTemplates.instantiateForAddressOfFunction((ICPPFunctionTemplate) result, null, args, point);
|
||||
|
||||
return result;
|
||||
|
@ -2677,7 +2677,7 @@ public class CPPSemantics {
|
|||
IType t= getNestedType(implicitParameterType, TDEF|REF|CVTYPE);
|
||||
if (SemanticUtil.calculateInheritanceDepth(s, t, data.getLookupPoint()) >= 0)
|
||||
return null;
|
||||
|
||||
|
||||
return CONTAINS_DEPENDENT_TYPES;
|
||||
}
|
||||
}
|
||||
|
@ -2714,7 +2714,7 @@ public class CPPSemantics {
|
|||
} else {
|
||||
if (CPPTemplates.isDependentType(paramType))
|
||||
return CONTAINS_DEPENDENT_TYPES;
|
||||
|
||||
|
||||
Context ctx= Context.ORDINARY;
|
||||
if (j == 0 && sourceLen == 1 && fn instanceof ICPPConstructor) {
|
||||
if (paramType instanceof ICPPReferenceType) {
|
||||
|
@ -2805,7 +2805,7 @@ public class CPPSemantics {
|
|||
prop= node.getPropertyInParent();
|
||||
parent= node.getParent();
|
||||
}
|
||||
|
||||
|
||||
IType targetType= null;
|
||||
if (prop == IASTDeclarator.INITIALIZER) {
|
||||
// Target is an object or reference being initialized
|
||||
|
@ -2989,7 +2989,7 @@ public class CPPSemantics {
|
|||
ICPPEvaluation arg1, ICPPEvaluation arg2) {
|
||||
if (op == null || arg1 == null || arg2 == null)
|
||||
return null;
|
||||
|
||||
|
||||
IType op1type = getNestedType(arg1.getTypeOrFunctionSet(point), TDEF | REF | CVTYPE);
|
||||
if (!isUserDefined(op1type) && !isUserDefined(
|
||||
getNestedType(arg2.getTypeOrFunctionSet(point), TDEF | REF | CVTYPE)))
|
||||
|
@ -3001,7 +3001,7 @@ public class CPPSemantics {
|
|||
} else {
|
||||
lookupNonMember= LookupMode.LIMITED_GLOBALS;
|
||||
}
|
||||
return findOverloadedOperator(point, new ICPPEvaluation[] {arg1, arg2},
|
||||
return findOverloadedOperator(point, new ICPPEvaluation[] {arg1, arg2},
|
||||
op1type, op, lookupNonMember);
|
||||
}
|
||||
|
||||
|
@ -3017,12 +3017,12 @@ public class CPPSemantics {
|
|||
|
||||
ICPPEvaluation[] args;
|
||||
if (placement == null) {
|
||||
args= new ICPPEvaluation[] {arg1, arg2};
|
||||
args= new ICPPEvaluation[] { arg1, arg2 };
|
||||
} else {
|
||||
args= new ICPPEvaluation[2+placement.length];
|
||||
args= new ICPPEvaluation[2 + placement.length];
|
||||
args[0]= arg1;
|
||||
args[1]= arg2;
|
||||
int i=2;
|
||||
int i= 2;
|
||||
for (IASTInitializerClause p : placement) {
|
||||
final ICPPASTInitializerClause arg = (ICPPASTInitializerClause) p;
|
||||
final ICPPEvaluation a = arg.getEvaluation();
|
||||
|
@ -3041,8 +3041,10 @@ public class CPPSemantics {
|
|||
if (type == null)
|
||||
return null;
|
||||
|
||||
ICPPEvaluation[] args = {new EvalFixed(type, LVALUE, Value.UNKNOWN),
|
||||
((ICPPASTExpression) expr.getOperand()).getEvaluation()};
|
||||
ICPPEvaluation[] args = {
|
||||
new EvalFixed(type, LVALUE, Value.UNKNOWN),
|
||||
((ICPPASTExpression) expr.getOperand()).getEvaluation()
|
||||
};
|
||||
return findOverloadedOperator(expr, args, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
|
||||
}
|
||||
|
||||
|
@ -3095,17 +3097,18 @@ public class CPPSemantics {
|
|||
IBinding binding = name.resolveBinding();
|
||||
if (!(binding instanceof ICPPVariable))
|
||||
return null;
|
||||
IType type;
|
||||
|
||||
IType type = ((ICPPVariable) binding).getType();
|
||||
try {
|
||||
type = SemanticUtil.getNestedType(((ICPPVariable) binding).getType(), TDEF | CVTYPE);
|
||||
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE);
|
||||
if (!(type instanceof ICPPClassType))
|
||||
return null;
|
||||
if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem)
|
||||
return null;
|
||||
|
||||
|
||||
final ICPPClassType classType = (ICPPClassType) type;
|
||||
if (initializer instanceof IASTEqualsInitializer) {
|
||||
// Copy initialization
|
||||
// Copy initialization.
|
||||
IASTEqualsInitializer eqInit= (IASTEqualsInitializer) initializer;
|
||||
ICPPASTInitializerClause initClause = (ICPPASTInitializerClause) eqInit.getInitializerClause();
|
||||
final ICPPEvaluation evaluation = initClause.getEvaluation();
|
||||
|
@ -3126,7 +3129,7 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
} else if (initializer instanceof ICPPASTInitializerList) {
|
||||
// List initialization
|
||||
// List initialization.
|
||||
ICPPEvaluation eval= ((ICPPASTInitializerList) initializer).getEvaluation();
|
||||
if (eval instanceof EvalInitList) {
|
||||
Cost c= Conversions.listInitializationSequence((EvalInitList) eval, type, UDCMode.ALLOWED, true, name);
|
||||
|
@ -3137,24 +3140,11 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
} else if (initializer instanceof ICPPASTConstructorInitializer) {
|
||||
// Direct Initialization
|
||||
final IASTInitializerClause[] arguments = ((ICPPASTConstructorInitializer) initializer).getArguments();
|
||||
CPPASTName astName = new CPPASTName();
|
||||
astName.setName(classType.getNameCharArray());
|
||||
astName.setOffsetAndLength((ASTNode) name);
|
||||
CPPASTIdExpression idExp = new CPPASTIdExpression(astName);
|
||||
idExp.setParent(name.getParent());
|
||||
idExp.setPropertyInParent(IASTFunctionCallExpression.FUNCTION_NAME);
|
||||
|
||||
LookupData data = new LookupData(astName);
|
||||
data.setFunctionArguments(false, arguments);
|
||||
data.qualified = true;
|
||||
data.foundItems = ClassTypeHelper.getConstructors(classType, name);
|
||||
binding = resolveAmbiguities(data);
|
||||
if (binding instanceof ICPPConstructor)
|
||||
return (ICPPConstructor) binding;
|
||||
// Direct initialization.
|
||||
return findImplicitlyCalledConstructor(classType,
|
||||
(ICPPASTConstructorInitializer) initializer, name);
|
||||
} else if (initializer == null) {
|
||||
// Default initialization
|
||||
// Default initialization.
|
||||
ICPPConstructor[] ctors = ClassTypeHelper.getConstructors(classType, name);
|
||||
for (ICPPConstructor ctor : ctors) {
|
||||
if (ctor.getRequiredArgumentCount() == 0)
|
||||
|
@ -3167,6 +3157,43 @@ public class CPPSemantics {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static ICPPConstructor findImplicitlyCalledConstructor(ICPPASTNewExpression expr) {
|
||||
IType type = getNestedType(expr.getExpressionType(), TDEF | REF | CVTYPE);
|
||||
if (!(type instanceof IPointerType))
|
||||
return null;
|
||||
type = ((IPointerType) type).getType();
|
||||
IASTInitializer initializer = expr.getInitializer();
|
||||
if (type instanceof ICPPClassType && initializer instanceof ICPPASTConstructorInitializer) {
|
||||
return findImplicitlyCalledConstructor((ICPPClassType) type,
|
||||
(ICPPASTConstructorInitializer) initializer, expr.getTypeId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ICPPConstructor findImplicitlyCalledConstructor(ICPPClassType classType,
|
||||
ICPPASTConstructorInitializer initializer, IASTNode typeId) {
|
||||
final IASTInitializerClause[] arguments = initializer.getArguments();
|
||||
CPPASTName astName = new CPPASTName();
|
||||
astName.setName(classType.getNameCharArray());
|
||||
astName.setOffsetAndLength((ASTNode) typeId);
|
||||
CPPASTIdExpression idExp = new CPPASTIdExpression(astName);
|
||||
idExp.setParent(typeId.getParent());
|
||||
idExp.setPropertyInParent(IASTFunctionCallExpression.FUNCTION_NAME);
|
||||
|
||||
LookupData data = new LookupData(astName);
|
||||
data.setFunctionArguments(false, arguments);
|
||||
data.qualified = true;
|
||||
data.foundItems = ClassTypeHelper.getConstructors(classType, typeId);
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = resolveAmbiguities(data);
|
||||
if (binding instanceof ICPPConstructor)
|
||||
return (ICPPConstructor) binding;
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ICPPFunction findImplicitlyCalledDestructor(ICPPASTDeleteExpression expr) {
|
||||
IType t = getTypeOfPointer(expr.getOperand().getExpressionType());
|
||||
if (!(t instanceof ICPPClassType))
|
||||
|
@ -3204,7 +3231,7 @@ public class CPPSemantics {
|
|||
return idExpression;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* For simplicity returns an operator of form RT (T, T) rather than RT (boolean, T, T)
|
||||
|
@ -3231,11 +3258,11 @@ public class CPPSemantics {
|
|||
|
||||
|
||||
static enum LookupMode {NO_GLOBALS, GLOBALS_IF_NO_MEMBERS, LIMITED_GLOBALS, ALL_GLOBALS}
|
||||
static ICPPFunction findOverloadedOperator(IASTNode point, ICPPEvaluation[] args, IType methodLookupType,
|
||||
static ICPPFunction findOverloadedOperator(IASTNode point, ICPPEvaluation[] args, IType methodLookupType,
|
||||
OverloadableOperator operator, LookupMode mode) {
|
||||
while (point instanceof IASTName)
|
||||
while (point instanceof IASTName)
|
||||
point= point.getParent();
|
||||
|
||||
|
||||
ICPPClassType callToObjectOfClassType= null;
|
||||
IType type2= null;
|
||||
if (args.length >= 2) {
|
||||
|
@ -3252,7 +3279,7 @@ public class CPPSemantics {
|
|||
methodData = new LookupData(operator.toCharArray(), null, point);
|
||||
methodData.setFunctionArguments(true, args);
|
||||
methodData.qualified = true; // (13.3.1.2.3)
|
||||
|
||||
|
||||
try {
|
||||
IScope scope = classType.getCompositeScope();
|
||||
if (scope == null)
|
||||
|
@ -3407,7 +3434,7 @@ public class CPPSemantics {
|
|||
} else if (methodData != null) {
|
||||
binding = resolveAmbiguities(methodData);
|
||||
}
|
||||
|
||||
|
||||
if (binding instanceof ICPPFunction)
|
||||
return (ICPPFunction) binding;
|
||||
} catch (DOMException e) {
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
|
@ -534,8 +535,9 @@ public class CPPTemplates {
|
|||
|
||||
ICPPASTTemplateDeclaration templateDeclaration = templates[0];
|
||||
IASTDeclaration decl = templateDeclaration.getDeclaration();
|
||||
while (decl instanceof ICPPASTTemplateDeclaration)
|
||||
while (decl instanceof ICPPASTTemplateDeclaration) {
|
||||
decl = ((ICPPASTTemplateDeclaration) decl).getDeclaration();
|
||||
}
|
||||
|
||||
IASTName name = null;
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
|
@ -557,6 +559,8 @@ public class CPPTemplates {
|
|||
IASTDeclarator dtor = ((IASTFunctionDefinition) decl).getDeclarator();
|
||||
dtor= ASTQueries.findInnermostDeclarator(dtor);
|
||||
name = dtor.getName();
|
||||
} else if (decl instanceof ICPPASTAliasDeclaration) {
|
||||
name = ((ICPPASTAliasDeclaration) decl).getAlias();
|
||||
}
|
||||
if (name == null)
|
||||
return null;
|
||||
|
@ -659,7 +663,7 @@ public class CPPTemplates {
|
|||
IBinding owner = template.getOwner();
|
||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
||||
IType instantiatedType = instantiateType(aliasedType, parameterMap, -1, within, id);
|
||||
return new CPPAliasTemplateInstance(id.toCharArray(), instantiatedType, aliasTemplate);
|
||||
return new CPPAliasTemplateInstance(id.toCharArray(), aliasTemplate, instantiatedType);
|
||||
}
|
||||
|
||||
// Class template.
|
||||
|
@ -830,7 +834,7 @@ public class CPPTemplates {
|
|||
} else if (decl instanceof ICPPAliasTemplate) {
|
||||
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl;
|
||||
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
|
||||
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), type, aliasTemplate);
|
||||
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
|
||||
} else if (decl instanceof IEnumeration || decl instanceof IEnumerator) {
|
||||
// TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter.
|
||||
spec = decl;
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
|
@ -68,7 +69,7 @@ public final class CPPVariableReadWriteFlags extends VariableReadWriteFlags {
|
|||
|
||||
private int rwInCtorInitializer(IASTNode node, int indirection, ICPPASTConstructorInitializer parent) {
|
||||
IASTNode grand= parent.getParent();
|
||||
if (grand instanceof IASTDeclarator) {
|
||||
if (grand instanceof IASTDeclarator || grand instanceof ICPPASTNewExpression) {
|
||||
// Look for a constructor being called.
|
||||
if (grand instanceof IASTImplicitNameOwner) {
|
||||
IASTImplicitName[] names = ((IASTImplicitNameOwner) grand).getImplicitNames();
|
||||
|
@ -87,7 +88,7 @@ public final class CPPVariableReadWriteFlags extends VariableReadWriteFlags {
|
|||
}
|
||||
}
|
||||
// Allow for initialization of primitive types.
|
||||
if (parent.getArguments().length == 1) {
|
||||
if (grand instanceof IASTDeclarator && parent.getArguments().length == 1) {
|
||||
IBinding binding= ((IASTDeclarator) grand).getName().getBinding();
|
||||
if (binding instanceof IVariable) {
|
||||
IType type= ((IVariable) binding).getType();
|
||||
|
|
|
@ -238,6 +238,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
return new HashSet<IASTDeclSpecifier>();
|
||||
}
|
||||
};
|
||||
|
||||
public static IBinding createBinding(IASTName name) {
|
||||
IASTNode parent = name.getParent();
|
||||
IBinding binding = null;
|
||||
|
@ -1978,71 +1979,79 @@ public class CPPVisitor extends ASTQueries {
|
|||
return type;
|
||||
}
|
||||
|
||||
private static IType createAutoType(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
||||
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
||||
return createAutoFunctionType(declSpec, (ICPPASTFunctionDeclarator) declarator);
|
||||
}
|
||||
ICPPASTInitializerClause autoInitClause= null;
|
||||
IASTNode parent = declarator.getParent().getParent();
|
||||
if (parent instanceof ICPPASTNewExpression) {
|
||||
IASTInitializer initializer = ((ICPPASTNewExpression) parent).getInitializer();
|
||||
if (initializer != null) {
|
||||
IASTInitializerClause[] arguments = ((ICPPASTConstructorInitializer) initializer).getArguments();
|
||||
if (arguments.length == 1) {
|
||||
autoInitClause = (ICPPASTInitializerClause) arguments[0];
|
||||
}
|
||||
private static IType createAutoType(final IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
||||
Set<IASTDeclSpecifier> recursionProtectionSet = autoTypeDeclSpecs.get();
|
||||
try {
|
||||
if (!recursionProtectionSet.add(declSpec)) {
|
||||
// Detected a self referring auto type, e.g.: auto x = x;
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
} else if (parent instanceof ICPPASTRangeBasedForStatement) {
|
||||
// See 6.5.4 The range-based for statement [stmt.ranged]
|
||||
ICPPASTRangeBasedForStatement forStmt= (ICPPASTRangeBasedForStatement) parent;
|
||||
IASTInitializerClause forInit = forStmt.getInitializerClause();
|
||||
IASTExpression beginExpr= null;
|
||||
if (forInit instanceof IASTExpression) {
|
||||
final IASTExpression expr = (IASTExpression) forInit;
|
||||
IType type= SemanticUtil.getNestedType(expr.getExpressionType(), TDEF|CVTYPE);
|
||||
if (type instanceof IArrayType) {
|
||||
beginExpr= expr.copy();
|
||||
}
|
||||
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
||||
return createAutoFunctionType(declSpec, (ICPPASTFunctionDeclarator) declarator);
|
||||
}
|
||||
if (beginExpr == null) {
|
||||
IASTImplicitName[] implicits= forStmt.getImplicitNames();
|
||||
if (implicits.length > 0) {
|
||||
IBinding b= implicits[0].getBinding();
|
||||
CPPASTName name= new CPPASTName();
|
||||
name.setBinding(b);
|
||||
if (b instanceof ICPPMethod && forInit instanceof IASTExpression) {
|
||||
beginExpr= new CPPASTFunctionCallExpression(
|
||||
new CPPASTFieldReference(name, (IASTExpression) forInit.copy()), NO_ARGS);
|
||||
} else {
|
||||
beginExpr= new CPPASTFunctionCallExpression(new CPPASTIdExpression(name), NO_ARGS);
|
||||
ICPPASTInitializerClause autoInitClause= null;
|
||||
IASTNode parent = declarator.getParent().getParent();
|
||||
if (parent instanceof ICPPASTNewExpression) {
|
||||
IASTInitializer initializer = ((ICPPASTNewExpression) parent).getInitializer();
|
||||
if (initializer != null) {
|
||||
IASTInitializerClause[] arguments = ((ICPPASTConstructorInitializer) initializer).getArguments();
|
||||
if (arguments.length == 1) {
|
||||
autoInitClause = (ICPPASTInitializerClause) arguments[0];
|
||||
}
|
||||
} else {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
} else if (parent instanceof ICPPASTRangeBasedForStatement) {
|
||||
// See 6.5.4 The range-based for statement [stmt.ranged]
|
||||
ICPPASTRangeBasedForStatement forStmt= (ICPPASTRangeBasedForStatement) parent;
|
||||
IASTInitializerClause forInit = forStmt.getInitializerClause();
|
||||
IASTExpression beginExpr= null;
|
||||
if (forInit instanceof IASTExpression) {
|
||||
final IASTExpression expr = (IASTExpression) forInit;
|
||||
IType type= SemanticUtil.getNestedType(expr.getExpressionType(), TDEF | CVTYPE);
|
||||
if (type instanceof IArrayType) {
|
||||
beginExpr= expr.copy();
|
||||
}
|
||||
}
|
||||
if (beginExpr == null) {
|
||||
IASTImplicitName[] implicits= forStmt.getImplicitNames();
|
||||
if (implicits.length > 0) {
|
||||
IBinding b= implicits[0].getBinding();
|
||||
CPPASTName name= new CPPASTName();
|
||||
name.setBinding(b);
|
||||
if (b instanceof ICPPMethod && forInit instanceof IASTExpression) {
|
||||
beginExpr= new CPPASTFunctionCallExpression(
|
||||
new CPPASTFieldReference(name, (IASTExpression) forInit.copy()), NO_ARGS);
|
||||
} else {
|
||||
beginExpr= new CPPASTFunctionCallExpression(new CPPASTIdExpression(name), NO_ARGS);
|
||||
}
|
||||
} else {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
}
|
||||
autoInitClause= new CPPASTUnaryExpression(IASTUnaryExpression.op_star, beginExpr);
|
||||
autoInitClause.setParent(forStmt);
|
||||
autoInitClause.setPropertyInParent(ICPPASTRangeBasedForStatement.INITIALIZER);
|
||||
} else if (parent instanceof IASTCompositeTypeSpecifier &&
|
||||
declSpec.getStorageClass() != IASTDeclSpecifier.sc_static) {
|
||||
// Non-static auto-typed class members are not allowed.
|
||||
return new ProblemType(ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD);
|
||||
} else {
|
||||
IASTInitializer initClause= declarator.getInitializer();
|
||||
if (initClause instanceof IASTEqualsInitializer) {
|
||||
autoInitClause= (ICPPASTInitializerClause) ((IASTEqualsInitializer) initClause).getInitializerClause();
|
||||
} else if (initClause instanceof ICPPASTInitializerClause) {
|
||||
autoInitClause= (ICPPASTInitializerClause) initClause;
|
||||
}
|
||||
}
|
||||
autoInitClause= new CPPASTUnaryExpression(IASTUnaryExpression.op_star, beginExpr);
|
||||
autoInitClause.setParent(forStmt);
|
||||
autoInitClause.setPropertyInParent(ICPPASTRangeBasedForStatement.INITIALIZER);
|
||||
} else if (parent instanceof IASTCompositeTypeSpecifier &&
|
||||
declSpec.getStorageClass() != IASTDeclSpecifier.sc_static) {
|
||||
// Non-static auto-typed class members are not allowed.
|
||||
return new ProblemType(ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD);
|
||||
} else {
|
||||
IASTInitializer initClause= declarator.getInitializer();
|
||||
if (initClause instanceof IASTEqualsInitializer) {
|
||||
autoInitClause= (ICPPASTInitializerClause) ((IASTEqualsInitializer) initClause).getInitializerClause();
|
||||
} else if (initClause instanceof ICPPASTInitializerClause) {
|
||||
autoInitClause= (ICPPASTInitializerClause) initClause;
|
||||
}
|
||||
return createAutoType(autoInitClause, declSpec, declarator);
|
||||
} finally {
|
||||
recursionProtectionSet.remove(declSpec);
|
||||
}
|
||||
return createAutoType(autoInitClause, declSpec, declarator);
|
||||
}
|
||||
|
||||
private static IType createAutoType(ICPPASTInitializerClause initClause, IASTDeclSpecifier declSpec,
|
||||
IASTDeclarator declarator) {
|
||||
// C++0x: 7.1.6.4
|
||||
if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) {
|
||||
// Detected a self referring auto type, e.g.: auto x = x;
|
||||
if (initClause == null) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
|
||||
|
@ -2050,27 +2059,23 @@ public class CPPVisitor extends ASTQueries {
|
|||
IType initType = null;
|
||||
ValueCategory valueCat= null;
|
||||
ICPPClassTemplate initializer_list_template = null;
|
||||
try {
|
||||
if (initClause instanceof ICPPASTInitializerList) {
|
||||
initializer_list_template = get_initializer_list(declSpec);
|
||||
if (initializer_list_template == null) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
type = (IType) CPPTemplates.instantiate(initializer_list_template,
|
||||
new ICPPTemplateArgument[] { new CPPTemplateTypeArgument(type) }, initClause);
|
||||
if (type instanceof IProblemBinding) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
}
|
||||
type = decorateType(type, declSpec, declarator);
|
||||
final ICPPEvaluation evaluation = initClause.getEvaluation();
|
||||
initType= evaluation.getTypeOrFunctionSet(declarator);
|
||||
valueCat= evaluation.getValueCategory(declarator);
|
||||
if (initType == null) {
|
||||
if (initClause instanceof ICPPASTInitializerList) {
|
||||
initializer_list_template = get_initializer_list(declSpec);
|
||||
if (initializer_list_template == null) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
} finally {
|
||||
autoTypeDeclSpecs.get().remove(declSpec);
|
||||
type = (IType) CPPTemplates.instantiate(initializer_list_template,
|
||||
new ICPPTemplateArgument[] { new CPPTemplateTypeArgument(type) }, initClause);
|
||||
if (type instanceof IProblemBinding) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
}
|
||||
type = decorateType(type, declSpec, declarator);
|
||||
final ICPPEvaluation evaluation = initClause.getEvaluation();
|
||||
initType= evaluation.getTypeOrFunctionSet(declarator);
|
||||
valueCat= evaluation.getValueCategory(declarator);
|
||||
if (initType == null || initType instanceof ISemanticProblem) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
ICPPFunctionTemplate template = new AutoTypeResolver(type);
|
||||
CPPTemplateParameterMap paramMap = new CPPTemplateParameterMap(1);
|
||||
|
|
|
@ -347,6 +347,16 @@ public class EvalBinary extends CPPEvaluation {
|
|||
return new EvalBinary(fOperator, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation arg1 = fArg1.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
ICPPEvaluation arg2 = fArg2.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (arg1 == fArg1 && arg2 == fArg2)
|
||||
return this;
|
||||
return new EvalBinary(fOperator, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.combinePackSize(fArg1.determinePackSize(tpMap), fArg2.determinePackSize(tpMap));
|
||||
|
|
|
@ -16,7 +16,6 @@ import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTBinaryTypeIdExpression.Operator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
|
@ -73,7 +72,7 @@ public class EvalBinaryTypeId extends CPPEvaluation {
|
|||
case __is_base_of:
|
||||
return CPPBasicType.BOOLEAN;
|
||||
}
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -128,6 +127,12 @@ public class EvalBinaryTypeId extends CPPEvaluation {
|
|||
return new EvalBinaryTypeId(fOperator, type1, type2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.combinePackSize(CPPTemplates.determinePackSize(fType1, tpMap),
|
||||
|
|
|
@ -25,7 +25,9 @@ import org.eclipse.cdt.core.dom.ast.IValue;
|
|||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
|
@ -37,12 +39,28 @@ import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class EvalBinding extends CPPEvaluation {
|
||||
private final IBinding fBinding;
|
||||
/**
|
||||
* The function owning the parameter if the binding is a function parameter, otherwise
|
||||
* {@code null}. May be computed lazily and remains {@code null} until computed.
|
||||
*/
|
||||
private ICPPFunction fParameterOwner;
|
||||
/**
|
||||
* The position of the parameter in the parameter list if the binding is a function parameter,
|
||||
* otherwise -1.
|
||||
*/
|
||||
private int fParameterPosition;
|
||||
/**
|
||||
* The binding represented by this evaluation. For a function parameter binding may be computed
|
||||
* lazily to avoid infinite recursion during unmarshalling of the evaluation. If #fBinding is
|
||||
* {@code null}, {@link #fParameterOwner} is guaranteed to be not {@code null} and vice versa.
|
||||
*/
|
||||
private IBinding fBinding;
|
||||
private final boolean fFixedType;
|
||||
|
||||
private IType fType;
|
||||
|
@ -52,15 +70,85 @@ public class EvalBinding extends CPPEvaluation {
|
|||
private boolean fCheckedIsTypeDependent;
|
||||
|
||||
public EvalBinding(IBinding binding, IType type) {
|
||||
fParameterPosition = -1;
|
||||
fBinding= binding;
|
||||
fType= type;
|
||||
fFixedType= type != null;
|
||||
}
|
||||
|
||||
public EvalBinding(ICPPFunction parameterOwner, int parameterPosition, IType type) {
|
||||
fParameterOwner = parameterOwner;
|
||||
fParameterPosition = parameterPosition;
|
||||
fType= type;
|
||||
fFixedType= type != null;
|
||||
}
|
||||
|
||||
public IBinding getBinding() {
|
||||
if (fBinding == null) {
|
||||
// fParameterOwner is guaranteed to be not null.
|
||||
ICPPParameter[] parameters = fParameterOwner.getParameters();
|
||||
fBinding = parameters[fParameterPosition];
|
||||
}
|
||||
return fBinding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the binding is a function parameter, returns its position in the parameter list,
|
||||
* otherwise returns -1
|
||||
*/
|
||||
public int getFunctionParameterPosition() {
|
||||
if (fParameterPosition < 0) {
|
||||
if (fBinding instanceof CPPParameter) {
|
||||
fParameterPosition = ((CPPParameter) fBinding).getParameterPosition();
|
||||
} else {
|
||||
ICPPFunction parameterOwner = getParameterOwner();
|
||||
if (parameterOwner != null) {
|
||||
ICPPParameter[] parameters = fParameterOwner.getParameters();
|
||||
fParameterPosition = findInArray(parameters, fBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fParameterPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a given object in an array.
|
||||
*
|
||||
* @param array the array to find the object in
|
||||
* @param obj the object to find
|
||||
* @return the index of the object in the array, or -1 if the object is not in the array
|
||||
*/
|
||||
private static int findInArray(Object[] array, Object obj) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (obj == array[i])
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the function owning the parameter if the binding is a function parameter,
|
||||
* otherwise {@code null}.
|
||||
*/
|
||||
public ICPPFunction getParameterOwner() {
|
||||
if (fParameterOwner == null && fBinding instanceof ICPPParameter) {
|
||||
IBinding owner = fBinding.getOwner();
|
||||
if (owner instanceof ICPPFunction)
|
||||
fParameterOwner = (ICPPFunction) owner;
|
||||
}
|
||||
return fParameterOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the binding is a template parameter, returns its ID, otherwise returns -1
|
||||
*/
|
||||
public int getTemplateParameterID() {
|
||||
// No need to call getBinding method since fBinding cannot be null if the evaluation
|
||||
// represents a template parameter.
|
||||
return fBinding instanceof ICPPTemplateParameter ?
|
||||
((ICPPTemplateParameter) fBinding).getParameterID() : -1;
|
||||
}
|
||||
|
||||
public IType getFixedType() {
|
||||
return fFixedType ? fType : null;
|
||||
}
|
||||
|
@ -88,18 +176,21 @@ public class EvalBinding extends CPPEvaluation {
|
|||
IType t= null;
|
||||
if (fFixedType) {
|
||||
t = fType;
|
||||
} else if (fBinding instanceof IEnumerator) {
|
||||
t= ((IEnumerator) fBinding).getType();
|
||||
} else if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
t= ((ICPPTemplateNonTypeParameter) fBinding).getType();
|
||||
} else if (fBinding instanceof IVariable) {
|
||||
t = ((IVariable) fBinding).getType();
|
||||
} else if (fBinding instanceof ICPPUnknownBinding) {
|
||||
return true;
|
||||
} else if (fBinding instanceof IFunction) {
|
||||
t= ((IFunction) fBinding).getType();
|
||||
} else {
|
||||
return false;
|
||||
} else {
|
||||
IBinding binding = getBinding();
|
||||
if (binding instanceof IEnumerator) {
|
||||
t= ((IEnumerator) binding).getType();
|
||||
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
t= ((ICPPTemplateNonTypeParameter) binding).getType();
|
||||
} else if (binding instanceof IVariable) {
|
||||
t = ((IVariable) binding).getType();
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
return true;
|
||||
} else if (binding instanceof IFunction) {
|
||||
t= ((IFunction) binding).getType();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return CPPTemplates.isDependentType(t);
|
||||
}
|
||||
|
@ -114,6 +205,7 @@ public class EvalBinding extends CPPEvaluation {
|
|||
}
|
||||
|
||||
private boolean computeIsValueDependent() {
|
||||
// No need to call getBinding() since a function parameter never has an initial value.
|
||||
if (fBinding instanceof IEnumerator) {
|
||||
return Value.isDependentValue(((IEnumerator) fBinding).getValue());
|
||||
}
|
||||
|
@ -141,23 +233,24 @@ public class EvalBinding extends CPPEvaluation {
|
|||
}
|
||||
|
||||
private IType computeType(IASTNode point) {
|
||||
if (fBinding instanceof IEnumerator) {
|
||||
return ((IEnumerator) fBinding).getType();
|
||||
IBinding binding = getBinding();
|
||||
if (binding instanceof IEnumerator) {
|
||||
return ((IEnumerator) binding).getType();
|
||||
}
|
||||
if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
IType type= ((ICPPTemplateNonTypeParameter) fBinding).getType();
|
||||
if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
IType type= ((ICPPTemplateNonTypeParameter) binding).getType();
|
||||
if (CPPTemplates.isDependentType(type))
|
||||
return new TypeOfDependentExpression(this);
|
||||
return prvalueType(type);
|
||||
}
|
||||
if (fBinding instanceof IVariable) {
|
||||
final IType type = ((IVariable) fBinding).getType();
|
||||
if (binding instanceof IVariable) {
|
||||
final IType type = ((IVariable) binding).getType();
|
||||
if (CPPTemplates.isDependentType(type))
|
||||
return new TypeOfDependentExpression(this);
|
||||
return SemanticUtil.mapToAST(glvalueType(type), point);
|
||||
}
|
||||
if (fBinding instanceof IFunction) {
|
||||
final IFunctionType type = ((IFunction) fBinding).getType();
|
||||
if (binding instanceof IFunction) {
|
||||
final IFunctionType type = ((IFunction) binding).getType();
|
||||
if (CPPTemplates.isDependentType(type))
|
||||
return new TypeOfDependentExpression(this);
|
||||
return SemanticUtil.mapToAST(type, point);
|
||||
|
@ -171,6 +264,7 @@ public class EvalBinding extends CPPEvaluation {
|
|||
return Value.create(this);
|
||||
|
||||
IValue value= null;
|
||||
// No need to call getBinding() since a function parameter never has an initial value.
|
||||
if (fBinding instanceof IInternalVariable) {
|
||||
value= ((IInternalVariable) fBinding).getInitialValue(Value.MAX_RECURSION_DEPTH);
|
||||
} else if (fBinding instanceof IVariable) {
|
||||
|
@ -189,7 +283,8 @@ public class EvalBinding extends CPPEvaluation {
|
|||
if (fBinding instanceof ICPPTemplateNonTypeParameter)
|
||||
return ValueCategory.PRVALUE;
|
||||
|
||||
if (fBinding instanceof IVariable || fBinding instanceof IFunction) {
|
||||
// fBinding can be null only when the evaluation represents a function parameter.
|
||||
if (fBinding instanceof IFunction || fBinding instanceof IVariable || fBinding == null) {
|
||||
return ValueCategory.LVALUE;
|
||||
}
|
||||
return ValueCategory.PRVALUE;
|
||||
|
@ -197,22 +292,39 @@ public class EvalBinding extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
|
||||
buffer.putByte(ITypeMarshalBuffer.EVAL_BINDING);
|
||||
buffer.marshalBinding(fBinding);
|
||||
byte firstByte = ITypeMarshalBuffer.EVAL_BINDING;
|
||||
ICPPFunction parameterOwner = getParameterOwner();
|
||||
if (parameterOwner != null) {
|
||||
// A function parameter cannot be marshalled directly. We are storing the owning
|
||||
// function and the parameter position instead.
|
||||
buffer.putByte((byte) (ITypeMarshalBuffer.EVAL_BINDING | ITypeMarshalBuffer.FLAG1));
|
||||
buffer.marshalBinding(parameterOwner);
|
||||
buffer.putShort((short) getFunctionParameterPosition());
|
||||
} else {
|
||||
buffer.putByte(firstByte);
|
||||
buffer.marshalBinding(fBinding);
|
||||
}
|
||||
buffer.marshalType(fFixedType ? fType : null);
|
||||
}
|
||||
|
||||
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
|
||||
IBinding binding= buffer.unmarshalBinding();
|
||||
IType type= buffer.unmarshalType();
|
||||
return new EvalBinding(binding, type);
|
||||
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
|
||||
ICPPFunction parameterOwner= (ICPPFunction) buffer.unmarshalBinding();
|
||||
int parameterPosition= buffer.getShort();
|
||||
IType type= buffer.unmarshalType();
|
||||
return new EvalBinding(parameterOwner, parameterPosition, type);
|
||||
} else {
|
||||
IBinding binding= buffer.unmarshalBinding();
|
||||
IType type= buffer.unmarshalType();
|
||||
return new EvalBinding(binding, type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
IBinding binding = fBinding;
|
||||
if (fBinding instanceof IEnumerator) {
|
||||
IBinding binding = getBinding();
|
||||
if (binding instanceof IEnumerator) {
|
||||
IEnumerator enumerator = (IEnumerator) binding;
|
||||
IType originalType = enumerator.getType();
|
||||
IType type = CPPTemplates.instantiateType(originalType, tpMap, packOffset, within, point);
|
||||
|
@ -221,23 +333,23 @@ public class EvalBinding extends CPPEvaluation {
|
|||
// TODO(sprigogin): Not sure if following condition is correct.
|
||||
if (type != originalType || value != originalValue)
|
||||
return new EvalFixed(type, ValueCategory.PRVALUE, value);
|
||||
} else if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) fBinding);
|
||||
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) binding);
|
||||
if (argument != null && argument.isNonTypeValue()) {
|
||||
return argument.getNonTypeEvaluation();
|
||||
}
|
||||
// TODO(sprigogin): Do we need something similar for pack expansion?
|
||||
} else if (fBinding instanceof ICPPUnknownBinding) {
|
||||
binding = resolveUnknown((ICPPUnknownBinding) fBinding, tpMap, packOffset, within, point);
|
||||
} else if (fBinding instanceof ICPPMethod) {
|
||||
IBinding owner = fBinding.getOwner();
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
binding = resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point);
|
||||
} else if (binding instanceof ICPPMethod) {
|
||||
IBinding owner = binding.getOwner();
|
||||
if (owner instanceof ICPPClassTemplate) {
|
||||
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner),
|
||||
tpMap, packOffset, within, point);
|
||||
}
|
||||
if (owner instanceof ICPPClassSpecialization) {
|
||||
binding = CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
|
||||
fBinding, point);
|
||||
binding, point);
|
||||
}
|
||||
}
|
||||
if (binding == fBinding)
|
||||
|
@ -245,21 +357,33 @@ public class EvalBinding extends CPPEvaluation {
|
|||
return new EvalBinding(binding, getFixedType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
int pos = getFunctionParameterPosition();
|
||||
if (pos >= 0) {
|
||||
ICPPEvaluation eval = parameterMap.getArgument(pos);
|
||||
if (eval != null)
|
||||
return eval;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
if (fBinding instanceof IEnumerator) {
|
||||
return CPPTemplates.determinePackSize(((IEnumerator) fBinding).getValue(), tpMap);
|
||||
IBinding binding = getBinding();
|
||||
if (binding instanceof IEnumerator) {
|
||||
return CPPTemplates.determinePackSize(((IEnumerator) binding).getValue(), tpMap);
|
||||
}
|
||||
if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
return CPPTemplates.determinePackSize((ICPPTemplateNonTypeParameter) fBinding, tpMap);
|
||||
if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
return CPPTemplates.determinePackSize((ICPPTemplateNonTypeParameter) binding, tpMap);
|
||||
}
|
||||
if (fBinding instanceof ICPPUnknownBinding) {
|
||||
return CPPTemplates.determinePackSize((ICPPUnknownBinding) fBinding, tpMap);
|
||||
if (binding instanceof ICPPUnknownBinding) {
|
||||
return CPPTemplates.determinePackSize((ICPPUnknownBinding) binding, tpMap);
|
||||
}
|
||||
|
||||
IBinding binding = fBinding;
|
||||
if (fBinding instanceof ICPPSpecialization) {
|
||||
binding = ((ICPPSpecialization) fBinding).getSpecializedBinding();
|
||||
if (binding instanceof ICPPSpecialization) {
|
||||
binding = ((ICPPSpecialization) binding).getSpecializedBinding();
|
||||
}
|
||||
|
||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
|
@ -275,6 +399,8 @@ public class EvalBinding extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
// No need to call getBinding method since fBinding cannot be null if the evaluation
|
||||
// represents a template parameter.
|
||||
return fBinding instanceof ICPPTemplateParameter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,6 +189,25 @@ public class EvalComma extends CPPEvaluation {
|
|||
return new EvalComma(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] args = fArguments;
|
||||
for (int i = 0; i < fArguments.length; i++) {
|
||||
ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (arg != fArguments[i]) {
|
||||
if (args == fArguments) {
|
||||
args = new ICPPEvaluation[fArguments.length];
|
||||
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
|
||||
}
|
||||
args[i] = arg;
|
||||
}
|
||||
}
|
||||
if (args == fArguments)
|
||||
return this;
|
||||
return new EvalComma(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
|
|
|
@ -94,6 +94,15 @@ public class EvalCompound extends CPPEvaluation {
|
|||
return new EvalCompound(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation delegate = fDelegate.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (delegate == fDelegate)
|
||||
return this;
|
||||
return new EvalCompound(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return fDelegate.determinePackSize(tpMap);
|
||||
|
|
|
@ -174,7 +174,7 @@ public class EvalConditional extends CPPEvaluation {
|
|||
} else if (void2 && void3) {
|
||||
fType= uqt2;
|
||||
} else {
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -204,10 +204,10 @@ public class EvalConditional extends CPPEvaluation {
|
|||
if (cost2.converts() || cost3.converts()) {
|
||||
if (cost2.converts()) {
|
||||
if (cost3.converts() || cost2.isAmbiguousUDC()) {
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
} else if (cost3.isAmbiguousUDC()) {
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public class EvalConditional extends CPPEvaluation {
|
|||
fType= t3;
|
||||
fValueCategory= vcat3;
|
||||
} else {
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ public class EvalConditional extends CPPEvaluation {
|
|||
if (fOverload != null) {
|
||||
fType= ExpressionTypes.typeFromFunctionCall(fOverload);
|
||||
} else {
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class EvalConditional extends CPPEvaluation {
|
|||
if (fType == null) {
|
||||
fType= Conversions.compositePointerType(t2, t3);
|
||||
if (fType == null) {
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,6 +336,18 @@ public class EvalConditional extends CPPEvaluation {
|
|||
return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation condition = fCondition.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
ICPPEvaluation positive = fPositive == null ?
|
||||
null : fPositive.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
ICPPEvaluation negative = fNegative.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (condition == fCondition && positive == fPositive && negative == fNegative)
|
||||
return this;
|
||||
return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = fCondition.determinePackSize(tpMap);
|
||||
|
|
|
@ -168,6 +168,18 @@ public class EvalFixed extends CPPEvaluation {
|
|||
return new EvalFixed(type, fValueCategory, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation eval = fValue.getEvaluation();
|
||||
if (eval == null)
|
||||
return this;
|
||||
eval = eval.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (eval == fValue.getEvaluation())
|
||||
return this;
|
||||
return new EvalFixed(fType, fValueCategory, Value.create(eval));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.determinePackSize(fValue, tpMap);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType;
|
||||
|
@ -22,14 +23,15 @@ import java.util.Arrays;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
|
@ -97,7 +99,7 @@ public class EvalFunctionCall extends CPPEvaluation {
|
|||
if (isTypeDependent())
|
||||
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) {
|
||||
return CPPSemantics.findOverloadedOperator(point, fArguments, t, OverloadableOperator.PAREN, LookupMode.NO_GLOBALS);
|
||||
}
|
||||
|
@ -119,11 +121,10 @@ public class EvalFunctionCall extends CPPEvaluation {
|
|||
if (overload != null)
|
||||
return ExpressionTypes.typeFromFunctionCall(overload);
|
||||
|
||||
|
||||
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) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
|
||||
if (t instanceof IPointerType) {
|
||||
|
@ -136,13 +137,16 @@ public class EvalFunctionCall extends CPPEvaluation {
|
|||
}
|
||||
return t;
|
||||
}
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
// TODO(sprigogin): Simulate execution of a function call if the value is not dependent.
|
||||
return Value.create(this);
|
||||
ICPPEvaluation eval = computeForFunctionCall(Value.MAX_RECURSION_DEPTH, point);
|
||||
if (eval instanceof EvalFixed)
|
||||
return ((EvalFixed) eval).getValue();
|
||||
eval = new EvalFixed(getTypeOrFunctionSet(point), PRVALUE, eval.getValue(point));
|
||||
return Value.create(eval);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,7 +155,6 @@ public class EvalFunctionCall extends CPPEvaluation {
|
|||
if (overload != null)
|
||||
return valueCategoryFromFunctionCall(overload);
|
||||
|
||||
|
||||
IType t= fArguments[0].getTypeOrFunctionSet(point);
|
||||
if (t instanceof IPointerType) {
|
||||
t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE);
|
||||
|
@ -204,6 +207,70 @@ public class EvalFunctionCall extends CPPEvaluation {
|
|||
return new EvalFunctionCall(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
if (maxdepth == 0)
|
||||
return EvalFixed.INCOMPLETE;
|
||||
|
||||
ICPPEvaluation[] args = fArguments;
|
||||
for (int i = 0; i < fArguments.length; i++) {
|
||||
ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (arg != fArguments[i]) {
|
||||
if (args == fArguments) {
|
||||
args = new ICPPEvaluation[fArguments.length];
|
||||
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
|
||||
}
|
||||
args[i] = arg;
|
||||
}
|
||||
}
|
||||
EvalFunctionCall eval = this;
|
||||
if (args != fArguments)
|
||||
eval = new EvalFunctionCall(args);
|
||||
return eval.computeForFunctionCall(maxdepth - 1, point);
|
||||
}
|
||||
|
||||
private ICPPEvaluation computeForFunctionCall(int maxdepth, IASTNode point) {
|
||||
if (isValueDependent())
|
||||
return this;
|
||||
ICPPFunction function = getOverload(point);
|
||||
if (function == null) {
|
||||
if (fArguments[0] instanceof EvalBinding) {
|
||||
IBinding binding = ((EvalBinding) fArguments[0]).getBinding();
|
||||
if (binding instanceof ICPPFunction)
|
||||
function = (ICPPFunction) binding;
|
||||
}
|
||||
}
|
||||
if (function == null)
|
||||
return this;
|
||||
ICPPEvaluation eval = CPPFunction.getReturnExpression(function);
|
||||
if (eval == null)
|
||||
return EvalFixed.INCOMPLETE;
|
||||
CPPFunctionParameterMap parameterMap = buildParameterMap(function);
|
||||
return eval.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
}
|
||||
|
||||
private CPPFunctionParameterMap buildParameterMap(ICPPFunction function) {
|
||||
ICPPParameter[] parameters = function.getParameters();
|
||||
CPPFunctionParameterMap map = new CPPFunctionParameterMap(parameters.length);
|
||||
int j = 1;
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
ICPPParameter param = parameters[i];
|
||||
if (param.isParameterPack()) {
|
||||
// The parameter pack consumes all remaining arguments.
|
||||
j = fArguments.length;
|
||||
} else {
|
||||
if (j < fArguments.length) {
|
||||
map.put(i, fArguments[j++]);
|
||||
} else if (param.hasDefaultValue()) {
|
||||
IValue value = param.getInitialValue();
|
||||
map.put(i, value.getEvaluation());
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
|
|
|
@ -170,6 +170,12 @@ public class EvalFunctionSet extends CPPEvaluation {
|
|||
return new EvalFunctionSet(new CPPFunctionSet(functions, arguments, null), fAddressOf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to resolve the function using the parameters of a function call.
|
||||
*
|
||||
|
|
|
@ -309,6 +309,17 @@ public class EvalID extends CPPEvaluation {
|
|||
return new EvalID(fieldOwner, nameOwner, fName, fAddressOf, fQualified, templateArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
if (fFieldOwner == null)
|
||||
return this;
|
||||
ICPPEvaluation fieldOwner = fFieldOwner.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (fieldOwner == fFieldOwner)
|
||||
return this;
|
||||
return new EvalID(fieldOwner, fNameOwner, fName, fAddressOf, fQualified, fTemplateArgs);
|
||||
}
|
||||
|
||||
private ICPPEvaluation resolveName(ICPPClassType nameOwner, ICPPTemplateArgument[] templateArgs,
|
||||
IASTNode point) {
|
||||
LookupData data = new LookupData(fName, templateArgs, point);
|
||||
|
|
|
@ -121,6 +121,25 @@ public class EvalInitList extends CPPEvaluation {
|
|||
return new EvalInitList(clauses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] clauses = fClauses;
|
||||
for (int i = 0; i < fClauses.length; i++) {
|
||||
ICPPEvaluation clause = fClauses[i].computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (clause != fClauses[i]) {
|
||||
if (clauses == fClauses) {
|
||||
clauses = new ICPPEvaluation[fClauses.length];
|
||||
System.arraycopy(fClauses, 0, clauses, 0, fClauses.length);
|
||||
}
|
||||
clauses[i] = clause;
|
||||
}
|
||||
}
|
||||
if (clauses == fClauses)
|
||||
return this;
|
||||
return new EvalInitList(clauses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
|
@ -176,8 +175,9 @@ public class EvalMemberAccess extends CPPEvaluation {
|
|||
* examine for type information.
|
||||
*/
|
||||
|
||||
ICPPEvaluation[] args= {new EvalFixed(type, LVALUE, Value.UNKNOWN)};
|
||||
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType, OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
|
||||
ICPPEvaluation[] args= { new EvalFixed(type, LVALUE, Value.UNKNOWN) };
|
||||
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType,
|
||||
OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
|
||||
if (op == null)
|
||||
break;
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class EvalMemberAccess extends CPPEvaluation {
|
|||
if (CPPTemplates.isDependentType(type))
|
||||
return returnUnnamed ? CPPUnknownMemberClass.createUnnamedInstance() : null;
|
||||
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -334,6 +334,12 @@ public class EvalMemberAccess extends CPPEvaluation {
|
|||
return new EvalMemberAccess(ownerType, fOwnerValueCategory, member, fIsPointerDeref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.determinePackSize(fOwnerType, tpMap);
|
||||
|
|
|
@ -165,6 +165,27 @@ public class EvalTypeId extends CPPEvaluation {
|
|||
return new EvalTypeId(type, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] args = fArguments;
|
||||
if (fArguments != null) {
|
||||
for (int i = 0; i < fArguments.length; i++) {
|
||||
ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (arg != fArguments[i]) {
|
||||
if (args == fArguments) {
|
||||
args = new ICPPEvaluation[fArguments.length];
|
||||
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
|
||||
}
|
||||
args[i] = arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args == fArguments)
|
||||
return this;
|
||||
return new EvalTypeId(fInputType, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = CPPTemplates.determinePackSize(fInputType, tpMap);
|
||||
|
|
|
@ -108,7 +108,7 @@ public class EvalUnary extends CPPEvaluation {
|
|||
if (fType != null)
|
||||
return fType instanceof TypeOfDependentExpression;
|
||||
|
||||
switch(fOperator) {
|
||||
switch (fOperator) {
|
||||
case op_alignOf:
|
||||
case op_not:
|
||||
case op_sizeof:
|
||||
|
@ -217,7 +217,7 @@ public class EvalUnary extends CPPEvaluation {
|
|||
if (type instanceof ISemanticProblem) {
|
||||
return type;
|
||||
}
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
case op_noexcept:
|
||||
case op_not:
|
||||
return CPPBasicType.BOOLEAN;
|
||||
|
@ -324,6 +324,16 @@ public class EvalUnary extends CPPEvaluation {
|
|||
return new EvalUnary(fOperator, argument, aoqn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation argument = fArgument.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||
if (argument == fArgument)
|
||||
return this;
|
||||
|
||||
return new EvalUnary(fOperator, argument, fAddressOfQualifiedNameBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return fArgument.determinePackSize(tpMap);
|
||||
|
|
|
@ -190,6 +190,12 @@ public class EvalUnaryTypeID extends CPPEvaluation {
|
|||
return new EvalUnaryTypeID(fOperator, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
int maxdepth, IASTNode point) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.determinePackSize(fOrigType, tpMap);
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope.ScopeLookupData;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
|
@ -336,12 +337,12 @@ public class LookupData extends ScopeLookupData {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean hasTypeOrMemberFunctionResult() {
|
||||
public boolean hasTypeOrMemberFunctionOrVariableResult() {
|
||||
if (foundItems == null)
|
||||
return false;
|
||||
if (foundItems instanceof Object[]) {
|
||||
for (Object item : (Object[]) foundItems) {
|
||||
if (item instanceof ICPPMethod || item instanceof IType) {
|
||||
if (item instanceof ICPPMethod || item instanceof IType || item instanceof IVariable) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
|
@ -636,7 +637,15 @@ public class TemplateArgumentDeduction {
|
|||
if (deducedArg != null) {
|
||||
deducedArg= CPPTemplates.instantiateArgument(deducedArg, tpMap, -1, null, point);
|
||||
if (deducedArg != null) {
|
||||
tpMap.put(tpar, deducedArg);
|
||||
if (deducedArg instanceof CPPTemplateTypeArgument) {
|
||||
CPPTemplateTypeArgument deducedTypeArg = (CPPTemplateTypeArgument) deducedArg;
|
||||
if (!(deducedTypeArg.getTypeValue() instanceof ISemanticProblem)) {
|
||||
tpMap.put(tpar, deducedArg);
|
||||
}
|
||||
} else {
|
||||
// TODO: Check for problems in non-type or template template parameters?
|
||||
tpMap.put(tpar, deducedArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||
|
||||
|
@ -24,28 +24,28 @@ class CompositeCParameter extends CompositeCBinding implements IParameter {
|
|||
|
||||
@Override
|
||||
public IType getType() {
|
||||
IType rtype = ((IParameter)rbinding).getType();
|
||||
IType rtype = ((IParameter) rbinding).getType();
|
||||
return cf.getCompositeType(rtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return ((IParameter)rbinding).isAuto();
|
||||
return ((IParameter) rbinding).isAuto();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return ((IParameter)rbinding).isExtern();
|
||||
return ((IParameter) rbinding).isExtern();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return ((IParameter)rbinding).isRegister();
|
||||
return ((IParameter) rbinding).isRegister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return ((IParameter)rbinding).isStatic();
|
||||
return ((IParameter) rbinding).isStatic();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||
|
||||
|
@ -24,18 +24,18 @@ class CompositeCVariable extends CompositeCBinding implements IVariable {
|
|||
|
||||
@Override
|
||||
public IType getType() {
|
||||
IType rtype = ((IVariable)rbinding).getType();
|
||||
IType rtype = ((IVariable) rbinding).getType();
|
||||
return cf.getCompositeType(rtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return ((IVariable)rbinding).isAuto();
|
||||
return ((IVariable) rbinding).isAuto();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return ((IVariable)rbinding).isExtern();
|
||||
return ((IVariable) rbinding).isExtern();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,11 +45,11 @@ class CompositeCVariable extends CompositeCBinding implements IVariable {
|
|||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return ((IVariable)rbinding).isStatic();
|
||||
return ((IVariable) rbinding).isStatic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue getInitialValue() {
|
||||
return ((IVariable)rbinding).getInitialValue();
|
||||
return ((IVariable) rbinding).getInitialValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -255,13 +256,24 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
}
|
||||
if (eval instanceof EvalBinding) {
|
||||
EvalBinding e= (EvalBinding) eval;
|
||||
IBinding a = e.getBinding();
|
||||
IType b = e.getFixedType();
|
||||
|
||||
IBinding a2 = getCompositeBinding((IIndexFragmentBinding) a);
|
||||
IType b2 = getCompositeType(b);
|
||||
if (a != a2 || b != b2)
|
||||
e= new EvalBinding(a2, b2);
|
||||
ICPPFunction parameterOwner = e.getParameterOwner();
|
||||
if (parameterOwner != null) {
|
||||
IType b = e.getFixedType();
|
||||
IBinding a2 = getCompositeBinding((IIndexFragmentBinding) parameterOwner);
|
||||
IType b2 = getCompositeType(b);
|
||||
if (parameterOwner != a2 || b != b2) {
|
||||
int parameterPosition = e.getFunctionParameterPosition();
|
||||
e= new EvalBinding((ICPPFunction) a2, parameterPosition, b2);
|
||||
}
|
||||
} else {
|
||||
IBinding a = e.getBinding();
|
||||
IType b = e.getFixedType();
|
||||
|
||||
IBinding a2 = getCompositeBinding((IIndexFragmentBinding) a);
|
||||
IType b2 = getCompositeType(b);
|
||||
if (a != a2 || b != b2)
|
||||
e= new EvalBinding(a2, b2);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
if (eval instanceof EvalComma) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -26,20 +26,20 @@ abstract class CompositeCPPBinding extends CompositeIndexBinding implements ICPP
|
|||
@Override
|
||||
public String[] getQualifiedName() {
|
||||
try {
|
||||
return ((ICPPBinding)rbinding).getQualifiedName();
|
||||
} catch(DOMException de) {
|
||||
CCorePlugin.log(de);
|
||||
return ((ICPPBinding) rbinding).getQualifiedName();
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
return ((ICPPBinding)rbinding).getQualifiedNameCharArray();
|
||||
return ((ICPPBinding) rbinding).getQualifiedNameCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
return ((ICPPBinding)rbinding).isGloballyQualified();
|
||||
return ((ICPPBinding) rbinding).isGloballyQualified();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
|
|
@ -18,10 +18,13 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPComputableFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
|
||||
class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction, ICPPComputableFunction {
|
||||
|
||||
public CompositeCPPFunction(ICompositesFactory cf, ICPPFunction rbinding) {
|
||||
super(cf, rbinding);
|
||||
|
@ -42,6 +45,11 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
|
|||
return ((ICPPFunction) rbinding).isMutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstexpr() {
|
||||
return ((ICPPFunction) rbinding).isConstexpr();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getFunctionScope() {
|
||||
return null;
|
||||
|
@ -129,4 +137,9 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation getReturnExpression() {
|
||||
return CPPFunction.getReturnExpression((ICPPFunction) rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -25,42 +25,42 @@ class CompositeCPPVariable extends CompositeCPPBinding implements ICPPVariable {
|
|||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return ((ICPPVariable)rbinding).isMutable();
|
||||
return ((ICPPVariable) rbinding).isMutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternC() {
|
||||
return ((ICPPVariable)rbinding).isExternC();
|
||||
return ((ICPPVariable) rbinding).isExternC();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
IType rtype = ((ICPPVariable)rbinding).getType();
|
||||
IType rtype = ((ICPPVariable) rbinding).getType();
|
||||
return cf.getCompositeType(rtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return ((ICPPVariable)rbinding).isAuto();
|
||||
return ((ICPPVariable) rbinding).isAuto();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return ((ICPPVariable)rbinding).isExtern();
|
||||
return ((ICPPVariable) rbinding).isExtern();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return ((ICPPVariable)rbinding).isRegister();
|
||||
return ((ICPPVariable) rbinding).isRegister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return ((ICPPVariable)rbinding).isStatic();
|
||||
return ((ICPPVariable) rbinding).isStatic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue getInitialValue() {
|
||||
return ((ICPPVariable)rbinding).getInitialValue();
|
||||
return ((ICPPVariable) rbinding).getInitialValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* IBM Corporation - initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||
|
@ -73,9 +73,9 @@ public class ExpressionEvaluator {
|
|||
if (LA() == IToken.tQUESTION) {
|
||||
consume();
|
||||
long r2 = expression();
|
||||
if (LA() == IToken.tCOLON)
|
||||
if (LA() == IToken.tCOLON) {
|
||||
consume();
|
||||
else {
|
||||
} else {
|
||||
throw new EvalException(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION, null);
|
||||
}
|
||||
long r3 = conditionalExpression();
|
||||
|
@ -139,11 +139,12 @@ public class ExpressionEvaluator {
|
|||
for (int t = LA(); t == IToken.tEQUAL || t == IToken.tNOTEQUAL; t = LA()) {
|
||||
consume();
|
||||
long r2 = relationalExpression();
|
||||
if (t == IToken.tEQUAL)
|
||||
if (t == IToken.tEQUAL) {
|
||||
r1 = (r1 == r2) ? 1 : 0;
|
||||
else
|
||||
} else {
|
||||
// t == tNOTEQUAL
|
||||
r1 = (r1 != r2) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
return r1;
|
||||
}
|
||||
|
@ -179,11 +180,12 @@ public class ExpressionEvaluator {
|
|||
for (int t = LA(); t == IToken.tSHIFTL || t == IToken.tSHIFTR; t = LA()) {
|
||||
consume();
|
||||
long r2 = additiveExpression();
|
||||
if (t == IToken.tSHIFTL)
|
||||
if (t == IToken.tSHIFTL) {
|
||||
r1 = r1 << r2;
|
||||
else
|
||||
} else {
|
||||
// t == tSHIFTR
|
||||
r1 = r1 >> r2;
|
||||
}
|
||||
}
|
||||
return r1;
|
||||
}
|
||||
|
@ -193,11 +195,12 @@ public class ExpressionEvaluator {
|
|||
for (int t = LA(); t == IToken.tPLUS || t == IToken.tMINUS; t = LA()) {
|
||||
consume();
|
||||
long r2 = multiplicativeExpression();
|
||||
if (t == IToken.tPLUS)
|
||||
if (t == IToken.tPLUS) {
|
||||
r1 = r1 + r2;
|
||||
else
|
||||
} else {
|
||||
// t == tMINUS
|
||||
r1 = r1 - r2;
|
||||
}
|
||||
}
|
||||
return r1;
|
||||
}
|
||||
|
@ -207,13 +210,14 @@ public class ExpressionEvaluator {
|
|||
for (int t = LA(); t == IToken.tSTAR || t == IToken.tDIV || t == IToken.tMOD; t = LA()) {
|
||||
consume();
|
||||
long r2 = unaryExpression();
|
||||
if (t == IToken.tSTAR)
|
||||
if (t == IToken.tSTAR) {
|
||||
r1 = r1 * r2;
|
||||
else if (r2 != 0) {
|
||||
if (t == IToken.tDIV)
|
||||
} else if (r2 != 0) {
|
||||
if (t == IToken.tDIV) {
|
||||
r1 = r1 / r2;
|
||||
else
|
||||
} else {
|
||||
r1 = r1 % r2; //tMOD
|
||||
}
|
||||
} else {
|
||||
throw new EvalException(IProblem.SCANNER_DIVIDE_BY_ZERO, null);
|
||||
}
|
||||
|
@ -328,7 +332,7 @@ public class ExpressionEvaluator {
|
|||
}
|
||||
|
||||
long getValue(Token t) throws EvalException {
|
||||
switch(t.getType()) {
|
||||
switch (t.getType()) {
|
||||
case IToken.tCHAR:
|
||||
return getChar(t.getCharImage(), 1);
|
||||
case IToken.tLCHAR:
|
||||
|
@ -386,7 +390,7 @@ public class ExpressionEvaluator {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
final char c= tokenImage[i];
|
||||
|
@ -398,7 +402,7 @@ public class ExpressionEvaluator {
|
|||
throw new EvalException(IProblem.SCANNER_BAD_CHARACTER, tokenImage);
|
||||
}
|
||||
final char d= tokenImage[i];
|
||||
switch(d) {
|
||||
switch (d) {
|
||||
case '\\': case '"': case '\'':
|
||||
return d;
|
||||
case 'a': return 7;
|
||||
|
@ -433,7 +437,7 @@ public class ExpressionEvaluator {
|
|||
result= result*base + digit;
|
||||
}
|
||||
for (; i < to; i++) {
|
||||
switch(tokenImage[i]) {
|
||||
switch (tokenImage[i]) {
|
||||
case 'u' : case 'l': case 'U': case 'L':
|
||||
break;
|
||||
default:
|
||||
|
@ -444,13 +448,13 @@ public class ExpressionEvaluator {
|
|||
}
|
||||
|
||||
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':
|
||||
return c-'0';
|
||||
return c - '0';
|
||||
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':
|
||||
return c-'A'+10;
|
||||
return c - 'A' + 10;
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
|
|
@ -227,10 +227,11 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* 135.0 - Changed marshalling of EvalUnary, bug 391001.
|
||||
* 136.0 - Extended CPPTemplateTypeArgument to include the original type, bug 392278.
|
||||
* 137.0 - Fixed serialization of very large types and template arguments, bug 392278.
|
||||
* 138.0 - Constexpr functions, bug 395238.
|
||||
*/
|
||||
private static final int MIN_SUPPORTED_VERSION= version(137, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(137, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(137, 0);
|
||||
private static final int MIN_SUPPORTED_VERSION= version(138, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(138, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(138, 0);
|
||||
|
||||
private static int version(int major, int minor) {
|
||||
return (major << 16) + minor;
|
||||
|
|
|
@ -297,16 +297,17 @@ abstract public class PDOMWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
} catch (RuntimeException e) {
|
||||
th= e;
|
||||
} catch (StackOverflowError e) {
|
||||
th= e;
|
||||
} catch (AssertionError e) {
|
||||
th= e;
|
||||
} finally {
|
||||
// Because the caller holds a read-lock, the result cache of the index is never cleared.
|
||||
// ==> Before releasing the lock for the last time in this ast, we clear the result cache.
|
||||
if (i == data.fSelectedFiles.length-1) {
|
||||
// Because the caller holds a read-lock, the result cache of the index is never
|
||||
// cleared. Before releasing the lock for the last time in this AST, we clear
|
||||
// the result cache.
|
||||
if (i == data.fSelectedFiles.length - 1) {
|
||||
data.fIndex.clearResultCache();
|
||||
}
|
||||
lock.release();
|
||||
|
|
|
@ -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
|
||||
* read access to the index.
|
||||
* read access to the index.
|
||||
* @since 5.2
|
||||
*/
|
||||
public class YieldableIndexLock {
|
||||
|
@ -30,7 +30,7 @@ public class YieldableIndexLock {
|
|||
|
||||
/**
|
||||
* Acquires the lock.
|
||||
*
|
||||
*
|
||||
* @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
|
||||
* for a read lock.
|
||||
* for a read lock.
|
||||
* @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() {
|
||||
return cumulativeLockTime;
|
||||
|
|
|
@ -78,6 +78,7 @@ public class Database {
|
|||
public static final int PTR_SIZE = 4; // size of a pointer in the database in bytes
|
||||
public static final int TYPE_SIZE = 2 + PTR_SIZE; // size of a type in the database in bytes
|
||||
public static final int VALUE_SIZE = TYPE_SIZE; // size of a value in the database in bytes
|
||||
public static final int EVALUATION_SIZE = TYPE_SIZE; // size of an evaluation in the database in bytes
|
||||
public static final int ARGUMENT_SIZE = TYPE_SIZE; // size of a template argument in the database in bytes
|
||||
public static final long MAX_DB_SIZE= ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS));
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
} else if (binding == null) {
|
||||
putByte(NULL_TYPE);
|
||||
} else {
|
||||
PDOMBinding pb= fLinkage.addTypeBinding(binding);
|
||||
PDOMNode pb= fLinkage.addTypeBinding(binding);
|
||||
if (pb == null) {
|
||||
putByte(UNSTORABLE_TYPE);
|
||||
} else {
|
||||
|
|
|
@ -115,7 +115,7 @@ public class FindBinding {
|
|||
public PDOMBinding getResult() {
|
||||
return fResult;
|
||||
}
|
||||
// IPDOMVisitor
|
||||
|
||||
@Override
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof PDOMBinding) {
|
||||
|
@ -127,7 +127,7 @@ public class FindBinding {
|
|||
}
|
||||
return false; /* do not visit children of node */
|
||||
}
|
||||
// IPDOMVisitor
|
||||
|
||||
@Override
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Bryan Wilkinson
|
||||
*/
|
||||
public interface IPDOMOverloader {
|
||||
|
||||
/**
|
||||
* @return the signature hash for this PDOM element, which will be unique
|
||||
* for all sibling IPDOMOverloaders with the same name.
|
||||
|
|
|
@ -423,7 +423,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
return map;
|
||||
}
|
||||
|
||||
public abstract PDOMBinding addTypeBinding(IBinding type) throws CoreException;
|
||||
public abstract PDOMBinding addTypeBinding(IBinding binding) throws CoreException;
|
||||
public abstract IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException;
|
||||
public abstract IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException;
|
||||
public abstract ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer typeMarshalBuffer) throws CoreException;
|
||||
|
@ -633,9 +633,41 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
}
|
||||
|
||||
public IValue loadValue(long offset) throws CoreException {
|
||||
TypeMarshalBuffer buffer = loadBuffer(offset, Database.VALUE_SIZE);
|
||||
if (buffer == null)
|
||||
return null;
|
||||
return buffer.unmarshalValue();
|
||||
}
|
||||
|
||||
public void storeEvaluation(long offset, ISerializableEvaluation eval) throws CoreException {
|
||||
final Database db= getDB();
|
||||
deleteEvaluation(db, offset);
|
||||
storeEvaluation(db, offset, eval);
|
||||
}
|
||||
|
||||
private void storeEvaluation(Database db, long offset, ISerializableEvaluation eval) throws CoreException {
|
||||
if (eval != null) {
|
||||
TypeMarshalBuffer bc= new TypeMarshalBuffer(this);
|
||||
bc.marshalEvaluation(eval, true);
|
||||
storeBuffer(db, offset, bc, Database.EVALUATION_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteEvaluation(Database db, long offset) throws CoreException {
|
||||
deleteSerializedData(db, offset, Database.EVALUATION_SIZE);
|
||||
}
|
||||
|
||||
public ISerializableEvaluation loadEvaluation(long offset) throws CoreException {
|
||||
TypeMarshalBuffer buffer = loadBuffer(offset, Database.EVALUATION_SIZE);
|
||||
if (buffer == null)
|
||||
return null;
|
||||
return buffer.unmarshalEvaluation();
|
||||
}
|
||||
|
||||
private TypeMarshalBuffer loadBuffer(long offset, int size) throws CoreException {
|
||||
final Database db= getDB();
|
||||
final byte firstByte= db.getByte(offset);
|
||||
byte[] data= null;
|
||||
byte[] data;
|
||||
switch (firstByte) {
|
||||
case TypeMarshalBuffer.INDIRECT_TYPE:
|
||||
data = loadLinkedSerializedData(db, offset + 1);
|
||||
|
@ -643,13 +675,13 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
case TypeMarshalBuffer.NULL_TYPE:
|
||||
return null;
|
||||
default:
|
||||
data= new byte[Database.VALUE_SIZE];
|
||||
data= new byte[size];
|
||||
db.getBytes(offset, data);
|
||||
break;
|
||||
}
|
||||
return new TypeMarshalBuffer(this, data).unmarshalValue();
|
||||
return new TypeMarshalBuffer(this, data);
|
||||
}
|
||||
|
||||
|
||||
public IIndexScope[] getInlineNamespaces() {
|
||||
return IIndexScope.EMPTY_INDEX_SCOPE_ARRAY;
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
|||
try {
|
||||
Database db = linkage.getDB();
|
||||
long bindingRec = db.getRecPtr(record + BINDING_REC_OFFSET);
|
||||
PDOMBinding binding = linkage.getBinding(bindingRec);
|
||||
IPDOMBinding binding = linkage.getBinding(bindingRec);
|
||||
return binding != null ? binding.getNameCharArray() : null;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
|
|
@ -80,27 +80,28 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
|
|||
|
||||
@Override
|
||||
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||
if (newBinding instanceof IFunction) {
|
||||
IFunction func= (IFunction) newBinding;
|
||||
IFunctionType newType;
|
||||
IParameter[] newParams;
|
||||
byte newAnnotation;
|
||||
newType= func.getType();
|
||||
newParams = func.getParameters();
|
||||
newAnnotation = PDOMCAnnotation.encodeAnnotation(func);
|
||||
|
||||
setType(linkage, newType);
|
||||
PDOMCParameter oldParams= getFirstParameter(null);
|
||||
setParameters(newParams);
|
||||
if (oldParams != null) {
|
||||
oldParams.delete(linkage);
|
||||
}
|
||||
getDB().putByte(record + ANNOTATIONS, newAnnotation);
|
||||
if (!(newBinding instanceof IFunction))
|
||||
return;
|
||||
|
||||
IFunction func= (IFunction) newBinding;
|
||||
IFunctionType newType;
|
||||
IParameter[] newParams;
|
||||
byte newAnnotation;
|
||||
newType= func.getType();
|
||||
newParams = func.getParameters();
|
||||
newAnnotation = PDOMCAnnotation.encodeAnnotation(func);
|
||||
|
||||
setType(linkage, newType);
|
||||
PDOMCParameter oldParams= getFirstParameter(null);
|
||||
setParameters(newParams);
|
||||
if (oldParams != null) {
|
||||
oldParams.delete(linkage);
|
||||
}
|
||||
getDB().putByte(record + ANNOTATIONS, newAnnotation);
|
||||
}
|
||||
|
||||
private void setType(PDOMLinkage linkage, IFunctionType ft) throws CoreException {
|
||||
linkage.storeType(record+FUNCTION_TYPE, ft);
|
||||
linkage.storeType(record + FUNCTION_TYPE, ft);
|
||||
}
|
||||
|
||||
private void setParameters(IParameter[] params) throws CoreException {
|
||||
|
@ -109,7 +110,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
|
|||
db.putInt(record + NUM_PARAMS, params.length);
|
||||
db.putRecPtr(record + FIRST_PARAM, 0);
|
||||
PDOMCParameter next= null;
|
||||
for (int i= params.length-1; i >= 0; --i) {
|
||||
for (int i= params.length; --i >= 0;) {
|
||||
next= new PDOMCParameter(linkage, this, params[i], next);
|
||||
}
|
||||
db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
|
||||
|
@ -134,8 +135,8 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
|
|||
public IFunctionType getType() {
|
||||
try {
|
||||
return (IFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +164,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
|
|||
|
||||
long next = db.getRecPtr(record + FIRST_PARAM);
|
||||
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 PDOMCParameter par = new PDOMCParameter(linkage, next, type);
|
||||
next= par.getNextPtr();
|
||||
result[i]= par;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
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.
|
||||
*/
|
||||
final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
|
||||
|
||||
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")
|
||||
public static final int RECORD_SIZE = FLAG_OFFSET + 1;
|
||||
static {
|
||||
assert RECORD_SIZE <= 22; // 23 would yield a 32-byte block
|
||||
}
|
||||
|
||||
|
||||
private final IType fType;
|
||||
public PDOMCParameter(PDOMLinkage linkage, long record, IType type) {
|
||||
super(linkage, record);
|
||||
|
@ -50,7 +49,7 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
|||
throws CoreException {
|
||||
super(linkage, parent, param.getNameCharArray());
|
||||
fType= null; // this constructor is used for adding parameters to the database, only.
|
||||
|
||||
|
||||
Database db = getDB();
|
||||
|
||||
db.putRecPtr(record + NEXT_PARAM, 0);
|
||||
|
@ -67,7 +66,7 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
|||
public int getNodeType() {
|
||||
return IIndexCBindingConstants.CPARAMETER;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
return fType;
|
||||
|
@ -75,13 +74,13 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
|||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
byte flag = 1<<PDOMCAnnotation.AUTO_OFFSET;
|
||||
byte flag = 1 << PDOMCAnnotation.AUTO_OFFSET;
|
||||
return hasFlag(flag, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
byte flag = 1<<PDOMCAnnotation.REGISTER_OFFSET;
|
||||
byte flag = 1 << PDOMCAnnotation.REGISTER_OFFSET;
|
||||
return hasFlag(flag, false);
|
||||
}
|
||||
|
||||
|
@ -137,15 +136,14 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
|||
public int getBindingConstant() {
|
||||
return getNodeType();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(PDOMLinkage linkage) throws CoreException {
|
||||
PDOMCParameter p= this;
|
||||
for (;;) {
|
||||
long rec = p.getNextPtr();
|
||||
p.flatDelete(linkage);
|
||||
if (rec == 0)
|
||||
if (rec == 0)
|
||||
return;
|
||||
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 {
|
||||
super.delete(linkage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public long getNextPtr() throws CoreException {
|
||||
long rec = getDB().getRecPtr(record + NEXT_PARAM);
|
||||
return rec;
|
||||
|
@ -164,7 +162,7 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
|||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
|
@ -192,8 +190,7 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
|||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return false;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue