diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildPathResolver.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildPathResolver.java index 61e9373206b..b3d9132b9aa 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildPathResolver.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuildPathResolver.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 Intel Corporation and others. + * Copyright (c) 2005, 2012 Intel 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 @@ -11,24 +11,22 @@ package org.eclipse.cdt.managedbuilder.core; /** - * this interface is to be implemented by the tool-integrator to provide some specific - * logic for resolving the build path variable values to the build paths + * This interface is to be implemented by the tool-integrator to provide some specific + * logic for resolving the build path variable values to the build paths. + *

+ * See extension point {@code org.eclipse.cdt.managedbuilder.core.buildDefinitions}, + * element {@code envVarBuildPath} attribute {@code buildPathResolver}. + * * @since 3.0 */ public interface IBuildPathResolver { - /** - * * @param pathType one of the IEnvVarBuildPath.BUILDPATH _xxx * @param variableName represents the name of the variable that holds the build paths - * @param variableValue represents the value of the value specified with the + * @param variableValue represents the value of the value specified with the * variableName argument * @param configuration represents configuration for which the build paths are requested */ - String[] resolveBuildPaths( - int pathType, - String variableName, - String variableValue, - IConfiguration configuration); + String[] resolveBuildPaths(int pathType, String variableName, String variableValue, IConfiguration configuration); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java index e309fb22ffa..24fc73e7c93 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. + * Copyright (c) 2003, 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 @@ -24,42 +24,32 @@ public class BuildObject implements IBuildObject { protected Version version = null; protected String managedBuildRevision = null; - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IBuildObject#getId() - */ @Override public String getId() { return id; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IBuildObject#setId(java.lang.String) - */ public void setId(String id) { this.id = id; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IBuildObject#getName() - */ @Override public String getName() { return name; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IBuildObject#setName(java.lang.String) - */ public void setName(String name) { this.name = name; } - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ + @SuppressWarnings("nls") @Override public String toString() { - return name; + if (name != null) { + return name; + } else { + return "id=" + id; + } } /** @@ -126,7 +116,7 @@ public class BuildObject implements IBuildObject { this.managedBuildRevision = managedBuildRevision; } - /* + /** * updates revision for this build object and all its children */ public void updateManagedBuildRevision(String revision){ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java index f19fed3634b..547db780397 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java @@ -165,8 +165,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv ManagedBuildManager.addExtensionToolChain(this); // Load the TargetPlatform child - IManagedConfigElement[] targetPlatforms = - element.getChildren(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME); + IManagedConfigElement[] targetPlatforms = element.getChildren(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME); if (targetPlatforms.length < 1 || targetPlatforms.length > 1) { // TODO: Report error } @@ -175,8 +174,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } // Load the Builder child - IManagedConfigElement[] builders = - element.getChildren(IBuilder.BUILDER_ELEMENT_NAME); + IManagedConfigElement[] builders = element.getChildren(IBuilder.BUILDER_ELEMENT_NAME); if (builders.length < 1 || builders.length > 1) { // TODO: Report error } @@ -342,13 +340,13 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv if (toolChain.isAbstract != null) { isAbstract = new Boolean(toolChain.isAbstract.booleanValue()); } - if (toolChain.scannerConfigDiscoveryProfileId != null) { - scannerConfigDiscoveryProfileId = new String(toolChain.scannerConfigDiscoveryProfileId); - } + if (toolChain.scannerConfigDiscoveryProfileId != null) { + scannerConfigDiscoveryProfileId = new String(toolChain.scannerConfigDiscoveryProfileId); + } isRcTypeBasedDiscovery = toolChain.isRcTypeBasedDiscovery; - supportsManagedBuild = toolChain.supportsManagedBuild; + supportsManagedBuild = toolChain.supportsManagedBuild; managedIsToolChainSupportedElement = toolChain.managedIsToolChainSupportedElement; managedIsToolChainSupported = toolChain.managedIsToolChainSupported; @@ -377,9 +375,8 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv String subName; if (toolChain.builder.getSuperClass() != null) { - subId = copyIds ? toolChain.builder.getId() : ManagedBuildManager.calculateChildId( - toolChain.builder.getSuperClass().getId(), - null); + subId = copyIds ? toolChain.builder.getId() : + ManagedBuildManager.calculateChildId(toolChain.builder.getSuperClass().getId(), null); subName = toolChain.builder.getSuperClass().getName(); } else { subId = copyIds ? toolChain.builder.getId() : ManagedBuildManager.calculateChildId( @@ -392,32 +389,31 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } // if (toolChain.targetPlatform != null) { - ITargetPlatform tpBase = toolChain.getTargetPlatform(); - if(tpBase != null){ - ITargetPlatform extTp = tpBase; - for(;extTp != null && !extTp.isExtensionElement();extTp = extTp.getSuperClass()) { - // empty body, the loop is to find extension element - } + ITargetPlatform tpBase = toolChain.getTargetPlatform(); + if(tpBase != null){ + ITargetPlatform extTp = tpBase; + for(;extTp != null && !extTp.isExtensionElement();extTp = extTp.getSuperClass()) { + // empty body, the loop is to find extension element + } - String subId; - if(copyIds){ - subId = tpBase.getId(); - } else { - subId = extTp != null ? ManagedBuildManager.calculateChildId(extTp.getId(), null): - ManagedBuildManager.calculateChildId(getId(), null); - } - String subName = tpBase.getName(); + String subId; + if(copyIds){ + subId = tpBase.getId(); + } else { + subId = extTp != null ? ManagedBuildManager.calculateChildId(extTp.getId(), null): + ManagedBuildManager.calculateChildId(getId(), null); + } + String subName = tpBase.getName(); -// if (toolChain.targetPlatform.getSuperClass() != null) { -// subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$ -// subName = toolChain.targetPlatform.getSuperClass().getName(); -// } else { -// subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$ -// subName = toolChain.targetPlatform.getName(); -// } - targetPlatform = new TargetPlatform(this, subId, subName, (TargetPlatform)tpBase); - } -// +// if (toolChain.targetPlatform.getSuperClass() != null) { +// subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$ +// subName = toolChain.targetPlatform.getSuperClass().getName(); +// } else { +// subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$ +// subName = toolChain.targetPlatform.getName(); +// } + targetPlatform = new TargetPlatform(this, subId, subName, (TargetPlatform)tpBase); + } } IConfiguration cfg = parentFolderInfo.getParent(); @@ -439,10 +435,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv if(subId == null){ if (extTool != null) { subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(extTool.getId(), null); - // subName = toolChild.getSuperClass().getName(); +// subName = toolChild.getSuperClass().getName(); } else { subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(toolChild.getId(), null); - // subName = toolChild.getName(); +// subName = toolChild.getName(); } } // version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId); @@ -544,10 +540,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv unusedChildren = SafeStringInterner.safeIntern(element.getAttribute(IProjectType.UNUSED_CHILDREN)); // isAbstract - String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT); - if (isAbs != null){ - isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$ - } + String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT); + if (isAbs != null){ + isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$ + } // Get the semicolon separated list of IDs of the error parsers errorParserIds = SafeStringInterner.safeIntern(element.getAttribute(ERROR_PARSERS)); @@ -562,10 +558,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv defaultLanguageSettingsProviderIds = element.getAttribute(LANGUAGE_SETTINGS_PROVIDERS); // Get the scanner config discovery profile id - scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID)); - String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY); - if(tmp != null) - isRcTypeBasedDiscovery = Boolean.valueOf(tmp); + scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID)); + String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY); + if(tmp != null) + isRcTypeBasedDiscovery = Boolean.valueOf(tmp); // Get the 'versionsSupported' attribute versionsSupported = SafeStringInterner.safeIntern(element.getAttribute(VERSIONS_SUPPORTED)); @@ -577,9 +573,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv if(tmp != null) supportsManagedBuild = Boolean.valueOf(tmp); - tmp = element.getAttribute(IS_SYSTEM); - if(tmp != null) - isTest = Boolean.valueOf(tmp).booleanValue(); + tmp = element.getAttribute(IS_SYSTEM); + if(tmp != null) + isTest = Boolean.valueOf(tmp).booleanValue(); // Get the comma-separated list of valid OS @@ -630,7 +626,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } - /* (non-Javadoc) + /** * Initialize the tool-chain information from the XML element * specified in the argument * @@ -659,7 +655,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv // Get the unused children, if any if (element.getAttribute(IProjectType.UNUSED_CHILDREN) != null) { - unusedChildren = SafeStringInterner.safeIntern(element.getAttribute(IProjectType.UNUSED_CHILDREN)); + unusedChildren = SafeStringInterner.safeIntern(element.getAttribute(IProjectType.UNUSED_CHILDREN)); } // isAbstract @@ -685,10 +681,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv targetToolIds = SafeStringInterner.safeIntern(element.getAttribute(TARGET_TOOL)); } - // Get the scanner config discovery profile id - if (element.getAttribute(SCANNER_CONFIG_PROFILE_ID) != null) { - scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID)); - } + // Get the scanner config discovery profile id + if (element.getAttribute(SCANNER_CONFIG_PROFILE_ID) != null) { + scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID)); + } // Get the 'versionSupported' attribute if (element.getAttribute(VERSIONS_SUPPORTED) != null) { @@ -731,10 +727,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } // Get the scanner config discovery profile id - scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID); - String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY); - if(tmp != null) - isRcTypeBasedDiscovery = Boolean.valueOf(tmp); + scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID); + String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY); + if(tmp != null) + isRcTypeBasedDiscovery = Boolean.valueOf(tmp); nonInternalBuilderId = SafeStringInterner.safeIntern(element.getAttribute(NON_INTERNAL_BUILDER_ID)); @@ -774,13 +770,13 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv element.setAttribute(SECONDARY_OUTPUTS, secondaryOutputIds); } - if (targetToolIds != null) { - element.setAttribute(TARGET_TOOL, targetToolIds); - } + if (targetToolIds != null) { + element.setAttribute(TARGET_TOOL, targetToolIds); + } - if (scannerConfigDiscoveryProfileId != null) { - element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId); - } + if (scannerConfigDiscoveryProfileId != null) { + element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId); + } // versionsSupported if (versionsSupported != null) { @@ -854,11 +850,11 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } //serialize user-defined macros -/* if(userDefinedMacros != null){ - ICStorageElement macrosElement = element.createChild(StorableMacros.MACROS_ELEMENT_NAME); - userDefinedMacros.serialize(macrosElement); - } -*/ +// if(userDefinedMacros != null){ +// ICStorageElement macrosElement = element.createChild(StorableMacros.MACROS_ELEMENT_NAME); +// userDefinedMacros.serialize(macrosElement); +// } + // Note: optionPathConverter cannot be specified in a project file because // an IConfigurationElement is needed to load it! if (pathconverterElement != null) { @@ -883,23 +879,17 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } catch (Exception e) { // TODO: issue an error message } -} + } /* * P A R E N T A N D C H I L D H A N D L I N G */ - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#getConfiguration() - */ @Override public IConfiguration getParent() { return config; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#createTargetPlatform(ITargetPlatform, String, String, boolean) - */ @Override public ITargetPlatform createTargetPlatform(ITargetPlatform superClass, String id, String name, boolean isExtensionElement) { targetPlatform = new TargetPlatform(this, superClass, id, name, isExtensionElement); @@ -907,9 +897,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return targetPlatform; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#getTargetPlatform() - */ @Override public ITargetPlatform getTargetPlatform() { if (targetPlatform == null) { @@ -920,9 +907,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return targetPlatform; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalTargetPlatform() - */ @Override public void removeLocalTargetPlatform() { if (targetPlatform == null) return; @@ -930,9 +914,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv setDirty(true); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#createBuilder(IBuilder, String, String, boolean) - */ @Override public IBuilder createBuilder(IBuilder superClass, String id, String name, boolean isExtensionElement) { builder = new Builder(this, superClass, id, name, isExtensionElement); @@ -944,9 +925,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv this.builder = builder; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#getBuilder() - */ @Override public IBuilder getBuilder() { if (builder == null) { @@ -957,9 +935,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return builder; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalBuilder() - */ @Override public void removeLocalBuilder() { if (builder == null) return; @@ -967,9 +942,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv setDirty(true); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#createTool(ITool, String, String, boolean) - */ @Override public ITool createTool(ITool superClass, String id, String name, boolean isExtensionElement) { Tool tool = new Tool(this, superClass, id, name, isExtensionElement); @@ -978,9 +950,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return tool; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#getTools() - */ @Override public ITool[] getTools() { ITool tools[] = getAllTools(false); @@ -1015,7 +984,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv break; } } - } + } // No Match? Insert it (may be re-ordered) if (j == tools.length) { Tool[] newTools = new Tool[tools.length + 1]; @@ -1071,18 +1040,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return filterUsedTools(all, false); } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTool(java.lang.String) - */ @Override public ITool getTool(String id) { Tool tool = getToolMap().get(id); return tool; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getToolsBySuperClassId(java.lang.String) - */ @Override public ITool[] getToolsBySuperClassId(String id) { List retTools = new ArrayList(); @@ -1160,15 +1123,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv * M O D E L A T T R I B U T E A C C E S S O R S */ - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSuperClass() - */ @Override public IToolChain getSuperClass() { return (IToolChain)superClass; } - /* (non-Javadoc) + /** * Access function to set the superclass element that is defined in * the base class. */ @@ -1190,17 +1150,11 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#getName() - */ @Override public String getName() { return (name == null && getSuperClass() != null) ? getSuperClass().getName() : name; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#isAbstract() - */ @Override public boolean isAbstract() { if (isAbstract != null) { @@ -1210,9 +1164,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IToolChain#getUnusedChildren() - */ @Override public String getUnusedChildren() { if (unusedChildren != null) { @@ -1221,9 +1172,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return EMPTY_STRING; // Note: no inheritance from superClass } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds() - */ @Override public String getErrorParserIds() { String ids = errorParserIds; @@ -1264,9 +1212,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return ids; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSecondaryOutputs() - */ @Override public IOutputType[] getSecondaryOutputs() { IOutputType[] types = null; @@ -1297,9 +1242,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return types; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTargetToolIds() - */ @Override public String getTargetToolIds() { if (targetToolIds == null) { @@ -1313,9 +1255,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return targetToolIds; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTargetToolList() - */ @Override public String[] getTargetToolList() { String IDs = getTargetToolIds(); @@ -1339,9 +1278,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return targetTools; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds(IConfiguration) - */ @Override public String getErrorParserIds(IConfiguration config) { String ids = errorParserIds; @@ -1353,9 +1289,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } if (ids == null) { // Collect the error parsers from my children - if (builder != null) { - ids = builder.getErrorParserIds(); - } + if (builder != null) { + ids = builder.getErrorParserIds(); + } ITool[] tools = config.getFilteredTools(); for (int i = 0; i < tools.length; i++) { ITool tool = tools[i]; @@ -1373,9 +1309,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return ids; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserList() - */ @Override public String[] getErrorParserList() { String parserIDs = getErrorParserIds(); @@ -1424,9 +1357,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return set; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getArchList() - */ @Override public String[] getArchList() { if (archList == null) { @@ -1441,9 +1371,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return archList.toArray(new String[archList.size()]); } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getOSList() - */ @Override public String[] getOSList() { if (osList == null) { @@ -1458,18 +1385,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return osList.toArray(new String[osList.size()]); } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setIsAbstract(boolean) - */ @Override public void setIsAbstract(boolean b) { isAbstract = new Boolean(b); setDirty(true); } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setErrorParserIds(String) - */ @Override public void setErrorParserIds(String ids) { String currentIds = getErrorParserIds(); @@ -1480,9 +1401,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setSecondaryOutputs() - */ @Override public void setSecondaryOutputs(String newIds) { if (secondaryOutputIds == null && newIds == null) return; @@ -1492,9 +1410,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setTargetToolIds() - */ @Override public void setTargetToolIds(String newIds) { if (targetToolIds == null && newIds == null) return; @@ -1504,9 +1419,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setOSList(String[]) - */ @Override public void setOSList(String[] OSs) { if (osList == null) { @@ -1520,9 +1432,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv setDirty(true); } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setArchList(String[]) - */ @Override public void setArchList(String[] archs) { if (archList == null) { @@ -1602,18 +1511,15 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return scannerConfigDiscoveryProfileId; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setScannerConfigDiscoveryProfileId(java.lang.String) - */ - @Override + @Override public void setScannerConfigDiscoveryProfileId(String profileId) { if (scannerConfigDiscoveryProfileId == null && profileId == null) return; - if (scannerConfigDiscoveryProfileId == null || - !scannerConfigDiscoveryProfileId.equals(profileId)) { - scannerConfigDiscoveryProfileId = profileId; - setDirty(true); - } - } + if (scannerConfigDiscoveryProfileId == null || + !scannerConfigDiscoveryProfileId.equals(profileId)) { + scannerConfigDiscoveryProfileId = profileId; + setDirty(true); + } + } /** * @return the pathconverterElement @@ -1622,9 +1528,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return pathconverterElement; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getPathConverter() - */ @Override public IOptionPathConverter getOptionPathConverter() { if (optionPathConverter != null) { @@ -1653,21 +1556,15 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv * O B J E C T S T A T E M A I N T E N A N C E */ - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#isExtensionElement() - */ @Override public boolean isExtensionElement() { return isExtensionToolChain; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#isDirty() - */ @Override public boolean isDirty() { // This shouldn't be called for an extension tool-chain - if (isExtensionToolChain) return false; + if (isExtensionToolChain) return false; // If I need saving, just say yes if (isDirty) return true; @@ -1696,9 +1593,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return isDirty; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setDirty(boolean) - */ @Override public void setDirty(boolean isDirty) { this.isDirty = isDirty; @@ -1766,15 +1660,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } if (extensions.length == 0){ tool.setOutputsAttribute(""); //$NON-NLS-1$ - continue; + continue; } } } } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getConvertToId() - */ @Override public String getConvertToId() { if (convertToId == null) { @@ -1788,9 +1679,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return convertToId; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setConvertToId(String) - */ @Override public void setConvertToId(String convertToId) { if (convertToId == null && this.convertToId == null) return; @@ -1801,9 +1689,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getVersionsSupported() - */ @Override public String getVersionsSupported() { if (versionsSupported == null) { @@ -1817,9 +1702,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return versionsSupported; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setVersionsSupported(String) - */ @Override public void setVersionsSupported(String versionsSupported) { if (versionsSupported == null && this.versionsSupported == null) return; @@ -1839,9 +1721,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return managedIsToolChainSupportedElement; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#isSupported() - */ @Override public boolean isSupported(){ if (managedIsToolChainSupported == null) { @@ -1857,7 +1736,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv if(managedIsToolChainSupported != null) return managedIsToolChainSupported.isSupported(this,null,null); - return true; + return true; } /** @@ -1875,9 +1754,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getEnvironmentVariableSupplier() - */ @Override public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){ if (environmentVariableSupplier != null) { @@ -1895,19 +1771,19 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return null; } - /* - * this method is called by the UserDefinedMacroSupplier to obtain user-defined - * macros available for this tool-chain - */ -/* public StorableMacros getUserDefinedMacros(){ - if(isExtensionToolChain) - return null; +// /* +// * this method is called by the UserDefinedMacroSupplier to obtain user-defined +// * macros available for this tool-chain +// */ +// public StorableMacros getUserDefinedMacros(){ +// if(isExtensionToolChain) +// return null; +// +// if(userDefinedMacros == null) +// userDefinedMacros = new StorableMacros(); +// return userDefinedMacros; +// } - if(userDefinedMacros == null) - userDefinedMacros = new StorableMacros(); - return userDefinedMacros; - } -*/ // public StorableEnvironment getUserDefinedEnvironment(){ // if(isExtensionToolChain) // return null; @@ -1936,9 +1812,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getBuildMacroSupplier() - */ @Override public IConfigurationBuildMacroSupplier getBuildMacroSupplier(){ if (buildMacroSupplier != null) { @@ -2139,9 +2012,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return currentMbsVersionConversionElement; } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String) - */ @Override public void updateManagedBuildRevision(String revision){ super.updateManagedBuildRevision(revision); @@ -2153,9 +2023,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv builder.updateManagedBuildRevision(revision); } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.internal.core.HoldsOptions#needsRebuild() - */ @Override public boolean needsRebuild() { if(rebuildState) @@ -2170,9 +2037,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv return super.needsRebuild(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.internal.core.HoldsOptions#setRebuildState(boolean) - */ @Override public void setRebuildState(boolean rebuild) { if(isExtensionElement() && rebuild) @@ -2643,10 +2507,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv } else { String version = ManagedBuildManager.getVersionFromIdAndVersion(getId()); if(version != null){ - StringBuffer buf = new StringBuffer(); - buf.append(name); - buf.append(" (v").append(version).append(")"); //$NON-NLS-1$ //$NON-NLS-2$ - name = buf.toString(); + StringBuffer buf = new StringBuffer(); + buf.append(name); + buf.append(" (v").append(version).append(")"); //$NON-NLS-1$ //$NON-NLS-2$ + name = buf.toString(); } } return name; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/BuildEnvVar.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/BuildEnvVar.java index 3765e3a7847..b767795381d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/BuildEnvVar.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/BuildEnvVar.java @@ -12,35 +12,40 @@ package org.eclipse.cdt.managedbuilder.internal.envvar; import org.eclipse.cdt.core.envvar.EnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; /** * a trivial implementation of the IBuildEnvironmentVariable - * + * * @since 3.0 */ public class BuildEnvVar extends EnvironmentVariable implements IBuildEnvironmentVariable { - public BuildEnvVar(String name, String value, int op, String delimiter){ - super(name, value, op, delimiter); - } - protected BuildEnvVar(){ - + } - + public BuildEnvVar(String name){ super(name); } - + public BuildEnvVar(String name, String value){ - super(name, value); + super(name, value); } public BuildEnvVar(String name, String value, String delimiter){ - super(name, value, delimiter); + super(name, value, delimiter); } - + + public BuildEnvVar(String name, String value, int op){ + super(name, value, op, EnvironmentVariableManager.getDefault().getDefaultDelimiter()); + } + + public BuildEnvVar(String name, String value, int op, String delimiter){ + super(name, value, op, delimiter); + } + public BuildEnvVar(IEnvironmentVariable var){ - super(var); + super(var); } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroProvider.java index 48924c1e091..76b2eaa0da9 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IBuildMacroProvider.java @@ -38,7 +38,7 @@ public interface IBuildMacroProvider{ * @param contextData represents the additional data needed by the Build Macro Provider * and Macro Suppliers in order to obtain the macro value. The type of the context data * differs depending on the context type and can be one of the following: - * 1. IFileContextData interface � used to represent currently selected file context + * 1. IFileContextData interface - used to represent currently selected file context * the IFileContextData interface is defined as follows: * public interface IFileContextData{ * IFile getFile(); @@ -46,13 +46,13 @@ public interface IBuildMacroProvider{ * } * NOTE: the IFileContextData is passed that represents the current file and the option * for that file because Macro Value Provider needs to know what option should be used - * as a context in case macro is not found for �current file� context + * as a context in case macro is not found for "current file" context * 2. IOptionContextData interface used to represent the currently selected option context - * 3. IConfiguration � used to represent the currently selected configuration context - * 4. IProject � used to represent current project context - * 5. IWorkspace � used to represent current workspace context - * 6. null � to represent the CDT and Eclipse installation context - * 7. null � to represent process environment context + * 3. IConfiguration - used to represent the currently selected configuration context + * 4. IProject - used to represent current project context + * 5. IWorkspace - used to represent current workspace context + * 6. null - to represent the CDT and Eclipse installation context + * 7. null - to represent process environment context * @param includeParentContexts specifies whether lower-precedence context macros should * be included */ @@ -107,7 +107,7 @@ public interface IBuildMacroProvider{ * expanded to. If null the BuildMacroException is thrown in case the string to be resolved * references inexistent macros * @param listDelimiter if not null, StringList macros are expanded as - * �< listDelimiter >< listDelimiter > ... � + * "< listDelimiter >< listDelimiter > ... " * otherwise the BuildMacroException is thrown in case the string to be resolved references * string-list macros * @param contextType context from which the macro search should be started @@ -157,7 +157,7 @@ public interface IBuildMacroProvider{ * expanded to. If null the BuildMacroException is thrown in case the string to be resolved * references inexistent macros * @param listDelimiter if not null, StringList macros are expanded as - * �< listDelimiter >< listDelimiter > ... � + * "< listDelimiter >< listDelimiter > ... " * otherwise the BuildMacroException is thrown in case the string to be resolved references * string-list macros * @param contextType context from which the macro search should be started @@ -200,7 +200,7 @@ public interface IBuildMacroProvider{ /** * * @return true if the specified expression can be treated as StringList - * 1. The string value is �${}� + * 1. The string value is "${}" */ public boolean isStringListValue(String value, int contextType, Object contextData) throws BuildMacroException; @@ -213,7 +213,7 @@ public interface IBuildMacroProvider{ * The BuildMacroException will contain the human-readable string describing * the inconsistency and the array of the IBuildMacro interfaces that will represent the macros that * caused the inconsistency. This information will be used in the UI to notify the user about - * the macro inconsistencies (see also the �User interface for viewing and editing Build Macros� + * the macro inconsistencies (see also the "User interface for viewing and editing Build Macros" * section of this design) */ public void checkIntegrity(int contextType, diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IConfigurationBuildMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IConfigurationBuildMacroSupplier.java index 144923dde29..7f5e3360532 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IConfigurationBuildMacroSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IConfigurationBuildMacroSupplier.java @@ -26,7 +26,7 @@ public interface IConfigurationBuildMacroSupplier { * @param configuration configuration * @param provider the instance of the build macro provider to be used for querying the * build macros from within the supplier. The supplier should use this provider to obtain - * the already defined build macros instead of using the �default� provider returned by the + * the already defined build macros instead of using the "default" provider returned by the * ManagedBuildManager.getBuildMacroProvider(). * The provider passed to a supplier will ignore searching macros for the levels * higher than the current supplier level, will query only the lower-precedence suppliers @@ -46,7 +46,7 @@ public interface IConfigurationBuildMacroSupplier { * @param configuration configuration * @param provider the instance of the build macro provider to be used for querying the * build macros from within the supplier. The supplier should use this provider to obtain - * the already defined build macros instead of using the �default� provider returned by the + * the already defined build macros instead of using the "default" provider returned by the * ManagedBuildManager.getBuildMacroProvider(). * The provider passed to a supplier will ignore searching macros for the levels * higher than the current supplier level, will query only the lower-precedence suppliers diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IProjectBuildMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IProjectBuildMacroSupplier.java index bdce1cf7489..4b4e6130399 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IProjectBuildMacroSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/macros/IProjectBuildMacroSupplier.java @@ -26,7 +26,7 @@ public interface IProjectBuildMacroSupplier { * @param project the instance of the managed project * @param provider the instance of the build macro provider to be used for querying the * build macros from within the supplier. The supplier should use this provider to obtain - * the already defined build macros instead of using the �default� provider returned by the + * the already defined build macros instead of using the "default" provider returned by the * ManagedBuildManager.getBuildMacroProvider(). * The provider passed to a supplier will ignore searching macros for the levels * higher than the current supplier level, will query only the lower-precedence suppliers @@ -46,7 +46,7 @@ public interface IProjectBuildMacroSupplier { * @param project the instance of the managed project * @param provider the instance of the build macro provider to be used for querying the * build macros from within the supplier. The supplier should use this provider to obtain - * the already defined build macros instead of using the �default� provider returned by the + * the already defined build macros instead of using the "default" provider returned by the * ManagedBuildManager.getBuildMacroProvider(). * The provider passed to a supplier will ignore searching macros for the levels * higher than the current supplier level, will query only the lower-precedence suppliers diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java index d43a686646a..bcaa60419a5 100755 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java @@ -73,20 +73,20 @@ import org.eclipse.core.runtime.IPath; * We can use this to ensure that the dependency files are up to date * by adding rules to the make file for generating the dependency files. * These rules are returned by the call to getDependencyCommands. - * However, this has a significant problem when we don�t want to build - * the build target, but only want to �clean� the configuration, + * However, this has a significant problem when we don't want to build + * the build target, but only want to "clean" the configuration, * for example. If we invoke make just to clean the configuration, * make will still update the dependency files if necessary, thereby * re-generating the dependency files only to immediately delete them. * The workaround suggested by the make documentation is to check for - * an invocation using the �clean� target, and to not include the + * an invocation using the "clean" target, and to not include the * dependency files it that case. For example, * * ifneq ($(MAKECMDGOALS),clean) * include $(DEPS) * endif * - * The restriction with this is that it only works if �clean� is the only + * The restriction with this is that it only works if "clean" is the only * target specified on the make command line. Therefore, the build * "clean" step must be invoked separately. */ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java index 814b5d1b62f..451fecd522f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java @@ -366,6 +366,14 @@ public class AST2BaseTest extends BaseTestCase { assertEquals(num, count); } + protected void assertSameType(IType expected, IType actual) { + assertNotNull(expected); + assertNotNull(actual); + assertTrue("Expected same types, but the types were: '" + + ASTTypeUtil.getType(expected, false) + "' and '" + ASTTypeUtil.getType(actual, false) + "'", + expected.isSameType(actual)); + } + protected void isExpressionStringEqual(IASTInitializerClause exp, String str) { String expressionString = ASTStringUtil.getExpressionString((IASTExpression) exp); assertEquals(str, expressionString); @@ -526,7 +534,25 @@ public class AST2BaseTest extends BaseTestCase { binding instanceof IProblemBinding); return (IProblemBinding) binding; } - + + public IProblemBinding assertProblem(String context, int len, int problemId) { + IProblemBinding problemBinding = assertProblem(context, len); + assertEquals(problemId, problemBinding.getID()); + return problemBinding; + } + + public IProblemBinding assertProblem(String context, String name) { + IBinding binding= binding(context, name); + assertTrue("Non-ProblemBinding for name: " + name, binding instanceof IProblemBinding); + return (IProblemBinding) binding; + } + + public IProblemBinding assertProblem(String context, String name, int problemId) { + IProblemBinding problemBinding = assertProblem(context, name); + assertEquals(problemId, problemBinding.getID()); + return problemBinding; + } + public T assertNonProblem(String section, int len) { if (len <= 0) len= section.length() + len; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 80574be3204..56ba6205b56 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -259,6 +259,12 @@ public class AST2CPPTests extends AST2BaseTest { assertEquals(declNames.length, i); assertEquals(defNames.length, j); } + + protected void assertSameType(IType first, IType second){ + assertNotNull(first); + assertNotNull(second); + assertTrue("Expected types to be the same, but first was: '" + first.toString() + "' and second was: '" + second + "'", first.isSameType(second)); + } // #define CURLOPTTYPE_OBJECTPOINT 10000 // #define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number @@ -9868,7 +9874,7 @@ public class AST2CPPTests extends AST2BaseTest { assertEquals(expectOverride, declarator.isOverride()); assertEquals(expectFinal, declarator.isFinal()); } - + // struct Base { // }; // struct S final : public Base { @@ -9893,9 +9899,8 @@ public class AST2CPPTests extends AST2BaseTest { assertInstance(sDefinition, ICPPASTCompositeTypeSpecifier.class); assertTrue(((ICPPASTCompositeTypeSpecifier)sDefinition).isFinal()); } - - - // struct S{ + + // struct S { // template // void foo(T t) final { // } @@ -9915,8 +9920,8 @@ public class AST2CPPTests extends AST2BaseTest { assertFalse(fooTemplate.isOverride()); assertTrue(fooTemplate.isFinal()); } - - // void foo(){ + + // void foo() { // int final, override; // final = 4; // override = 2; @@ -9924,17 +9929,17 @@ public class AST2CPPTests extends AST2BaseTest { public void testFinalAndOverrideVariables() throws Exception { parseAndCheckBindings(); } - - // struct S{ + + // struct S { // int i; // }; - // void foo(struct S final){ + // void foo(struct S final) { // final.i = 23; // } public void testFinalParameter() throws Exception { parseAndCheckBindings(); } - + // struct S1 {}; // S1 s1; // const int i= 1; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 5e44688939c..f0dea6d3d14 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -11,6 +11,7 @@ * Bryan Wilkinson (QNX) * Andrew Ferguson (Symbian) * Sergey Prigogin (Google) + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -50,6 +51,7 @@ import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IQualifierType; 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.ITypedef; import org.eclipse.cdt.core.dom.ast.IVariable; @@ -58,6 +60,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; @@ -87,6 +91,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope; @@ -6079,7 +6085,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testIsPOD_367993() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, true); } - + // template class A { // public: // static void Delegate(void* thiz) { ((T*)thiz->*M)(); } @@ -6102,7 +6108,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testDeductionOfNonTypeTemplateArg_372587() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, true); } - + // template void b(_Functor __f) {} // template void f(T __first, T __last, const V& __val) {} // template void f(T __first, T __last, const T& __val) {} @@ -6111,8 +6117,8 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testFunctionSetWithNonMatchingTemplateArgs_379604() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, true); - } - + } + // template struct C { // typedef decltype(&T::m) dtm; // }; @@ -6127,8 +6133,8 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testPointerToMemberAsDependentExpression_391001() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, true); - } - + } + // class Memory { }; // Memory memory; // template struct Container { @@ -6142,8 +6148,8 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testAddressAsTemplateArgument_391190() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, true); - } - + } + // template struct CT { // const static int const_min= 1; // }; @@ -6152,5 +6158,575 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplateIDAmbiguity_393959() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, true); - } + } + + // template class CT { + // void m() { + // template using Alias= T; // nesting level 1 + // Alias x; + // } + // }; + public void testNestedAliasDeclarationNestingLevel() throws Exception { + final String code = getAboveComment(); + BindingAssertionHelper bh= new BindingAssertionHelper(code, true); + + ICPPAliasTemplate templateParameterAlias = bh.assertNonProblem("Alias=", "Alias", ICPPAliasTemplate.class); + ICPPTemplateParameter aliasParameterT= templateParameterAlias.getTemplateParameters()[0]; + assertEquals(1, aliasParameterT.getTemplateNestingLevel()); + + ICPPAliasTemplateInstance aliasIntInstance = bh.assertNonProblem("Alias", ICPPAliasTemplateInstance.class); + IType typeOfAliasIntInstance = aliasIntInstance.getType(); + assertTrue(typeOfAliasIntInstance instanceof ICPPBasicType); + assertEquals(((ICPPBasicType)typeOfAliasIntInstance).getKind(), IBasicType.Kind.eInt); + + parseAndCheckBindings(code); + } + + // template class CT; + // template using Alias= CT; // nesting level 0 + // template class CT { // nesting level 0 + // typedef Alias TYPE; + // }; + public void testAliasDeclarationNestingLevel() throws Exception { + final String code = getAboveComment(); + BindingAssertionHelper bh= new BindingAssertionHelper(code, true); + + ICPPAliasTemplate templateParameterAlias = bh.assertNonProblem("Alias=", "Alias", ICPPAliasTemplate.class); + ICPPTemplateParameter aliasParameterT = templateParameterAlias.getTemplateParameters()[0]; + assertEquals(0, aliasParameterT.getTemplateNestingLevel()); + + ICPPTemplateDefinition templateCT = bh.assertNonProblem("CT {", "CT", ICPPTemplateDefinition.class); + ICPPTemplateParameter templateParameterT = templateCT.getTemplateParameters()[0]; + assertEquals(0, templateParameterT.getTemplateNestingLevel()); + + parseAndCheckBindings(code); + } + + // struct S { + // int x; + // }; + // using Alias = S; + // void foo() { + // Alias myA; + // 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(); + + assertInstances(collector, S, 2); + assertInstances(collector, x, 2); + assertInstances(collector, Alias, 2); + assertInstances(collector, foo, 1); + assertInstances(collector, myA, 2); + } + + // template + // struct S { + // T x; + // }; + // using Alias = S; + // void foo() { + // Alias myA; + // 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(); + + assertInstances(collector, S, 2); + assertInstances(collector, Alias, 2); + assertInstances(collector, myA, 2); + assertEquals(x, xRef.getSpecializedBinding()); + } + + // template + // using Alias = int; + // void foo() { + // Alias myA; + // 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(); + assertInstances(collector, Alias, 2); + assertSameType(AliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0)); + } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S; + // void foo() { + // TAlias 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(); + + assertInstances(collector, S, 2); + assertInstances(collector, T, 2); + assertEquals(T, TRef); + assertInstances(collector, TAlias, 2); + assertInstances(collector, myA, 2); + assertEquals(t, tRef.getSpecializedBinding()); + ICPPDeferredClassInstance aliasedType = (ICPPDeferredClassInstance) TAlias.getType(); + assertEquals(S, aliasedType.getClassTemplate()); + } + + // template + // struct S { + // T1 t1; + // T2 t2; + // T3 t3; + // }; + // template + // using TAlias = S; + // void foo() { + // TAlias myA; + // myA.t1 = 42; + // myA.t2 = 42.0f; + // 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(); + + ICPPTemplateParameter P1 = (ICPPTemplateParameter) collector.getName(10).resolveBinding(); + ICPPTemplateParameter P2 = (ICPPTemplateParameter) collector.getName(11).resolveBinding(); + + ICPPTemplateParameter P1Ref = (ICPPTemplateParameter) collector.getName(16).resolveBinding(); + ICPPTemplateParameter P2Ref = (ICPPTemplateParameter) collector.getName(15).resolveBinding(); + + ICPPAliasTemplateInstance TAliasInstance = (ICPPAliasTemplateInstance) collector.getName(18).resolveBinding(); + 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(); + + assertEquals(P1, P1Ref); + assertEquals(P2, P2Ref); + + assertEquals(t1, t1Ref.getSpecializedBinding()); + assertEquals(t2, t2Ref.getSpecializedBinding()); + assertEquals(t3, t3Ref.getSpecializedBinding()); + assertSameType(new CPPBasicType(IBasicType.Kind.eInt, 0), aliasedTypeInstance.getTemplateArguments()[0].getTypeValue()); + assertSameType(new CPPBasicType(IBasicType.Kind.eFloat, 0), aliasedTypeInstance.getTemplateArguments()[1].getTypeValue()); + assertSameType(new CPPBasicType(IBasicType.Kind.eBoolean, 0), aliasedTypeInstance.getTemplateArguments()[2].getTypeValue()); + } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S

; + // void foo() { + // TAlias > myA; + // myA.t = S(); + // } + 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(); + + assertEquals(t, tRef.getSpecializedBinding()); + assertSameType(TAliasSInt, (IType)tRef.getOwner()); + } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S

; + // void foo() { + // S > myA; + // myA.t = S(); + // } + 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(); + + assertEquals(t, tRef.getSpecializedBinding()); + assertEquals(STAliasInt, tRef.getOwner()); + } + + // template + // struct S { + // int buff [Size]; + // }; + // template + // using TAlias = S; + // void foo() { + // TAlias<5, 4> myA; + // 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(); + + assertEquals(buff, buffRef.getSpecializedBinding()); + assertEquals(buffRef.getTemplateParameterMap().getArgument(0).getNonTypeValue().numericalValue(), new Long(4)); + assertEquals(buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numericalValue(), new Long(5)); + } + + // template + // struct S { + // T buff [Size]; + // }; + // template + // using TAlias = S; + // void foo() { + // TAlias<> myA; + // 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(); + + assertEquals(buff, buffRef.getSpecializedBinding()); + assertSameType(buffRef.getTemplateParameterMap().getArgument(0).getTypeValue(), new CPPBasicType(IBasicType.Kind.eInt, 0)); + assertEquals(buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numericalValue(), new Long(5)); + } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S >; + // void foo() { + // TAlias myA; + // myA.t = S(); + // } + 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(); + + assertEquals(t, tRef.getSpecializedBinding()); + assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint); + } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S; + // void bar(TAlias arg){ + // } + // void foo() { + // TAlias myA; + // bar(myA); + // S myS; + // 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(); + + assertEquals(bar, barRefAlias); + assertEquals(bar, barRefSInt); + } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S; + // void bar(S arg){ + // } + // void foo() { + // TAlias myA; + // bar(myA); + // } + public void testTemplatedAliasAsFunctionArgument() 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(); + + assertEquals(bar, barRefAlias); + } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S; + // void bar(S arg){ + // } + // void bar(TAlias arg){ + // } + public void testTemplatedAliasRedefinitionOfSameFunction() throws Exception { + BindingAssertionHelper bh= getAssertionHelper(); + bh.assertNonProblem("bar(S", "bar", ICPPFunction.class); + bh.assertProblem("bar(TAlias", "bar", ISemanticProblem.BINDING_INVALID_REDEFINITION); + } + + // template struct vector{}; + // template struct Alloc{}; + // template using Vec = vector >; + // template class TT> + // void f(TT); + // template class TT> + // void g(TT >); + // void foo(){ + // Vec v; + // g(v); + // f(v); + // } + public void testTemplatedAliasDeduction() throws Exception { + BindingAssertionHelper bh= getAssertionHelper(); + bh.assertNonProblem("g(v)", "g", ICPPFunction.class); + bh.assertProblem("f(v)", "f", ISemanticProblem.BINDING_NOT_FOUND); + } + + // using function = void (&)(int); + // void foo(int) { + // function f = &foo; + // } + public void testSimpleFunctionAliasDeclaration() throws Exception { + final String code = getAboveComment(); + IASTTranslationUnit ast = parseAndCheckBindings(code); + CPPNameCollector collector = new CPPNameCollector(); + ast.accept(collector); + + ITypedef function = (ITypedef) collector.getName(0).resolveBinding(); + ICPPFunction foo = (ICPPFunction) collector.getName(2).resolveBinding(); + + assertInstances(collector, function, 2); + assertInstances(collector, foo, 2); + assertSameType(((ICPPReferenceType)function.getType()).getType(), foo.getType()); + } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S&; + // void foo() { + // S myS; + // TAlias myA = myS; + // 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(); + assertSameType(new CPPReferenceType(SInt, false), TAliasInt); + + } + + // template + // using function = void (int); + // void foo(int) { + // function f = &foo; + // } + public void testSimpleFunctionTemplateAliasDeclaration() throws Exception { + final String code = getAboveComment(); + IASTTranslationUnit ast = parseAndCheckBindings(code); + CPPNameCollector collector = new CPPNameCollector(); + ast.accept(collector); + + ICPPAliasTemplate function = (ICPPAliasTemplate) collector.getName(1).resolveBinding(); + ICPPFunction foo = (ICPPFunction) collector.getName(3).resolveBinding(); + ICPPAliasTemplateInstance functionInt = (ICPPAliasTemplateInstance) collector.getName(5).resolveBinding(); + + assertInstances(collector, function, 2); + assertInstances(collector, foo, 2); + assertSameType(foo.getType(),functionInt); + } + + // template + // using function = void (&)(int); + // void foo(int) { + // function f = &foo; + // } + public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Exception { + final String code = getAboveComment(); + IASTTranslationUnit ast = parseAndCheckBindings(code); + CPPNameCollector collector = new CPPNameCollector(); + ast.accept(collector); + + ICPPAliasTemplate function = (ICPPAliasTemplate) collector.getName(1).resolveBinding(); + ICPPFunction foo = (ICPPFunction) collector.getName(3).resolveBinding(); + ICPPAliasTemplateInstance functionInt = (ICPPAliasTemplateInstance) collector.getName(5).resolveBinding(); + + assertInstances(collector, function, 2); + assertInstances(collector, foo, 2); + assertSameType(new CPPReferenceType(foo.getType(), false),functionInt.getType()); + } + + // template + // struct S { + // T t; + // }; + // template class TA> + // using TAlias = S; + // void foo() { + // TAlias > myA; + // myA.t = S(); + // } + public void testTemplatedAliasTemplateParameter() 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(); + + assertEquals(t, tRef.getSpecializedBinding()); + assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint); + } + + // namespace NS { + // template + // struct S { + // T t; + // }; + // template + // using Alias = S; + // } + // using namespace NS; + // Alias intAlias; + public void testAliasDeclarationContext() throws Exception { + final String code = getAboveComment(); + IASTTranslationUnit ast = parseAndCheckBindings(code); + CPPNameCollector collector = new CPPNameCollector(); + ast.accept(collector); + + ICPPAliasTemplateInstance AliasInt = (ICPPAliasTemplateInstance) collector.getName(11).resolveBinding(); + assertEquals("Alias", AliasInt.getName()); + assertEquals("NS", AliasInt.getQualifiedName()[0]); + assertEquals("Alias", AliasInt.getQualifiedName()[1]); + + ICPPNamespace namespaceNS = (ICPPNamespace) collector.getName(0).resolveBinding(); + assertEquals(namespaceNS, AliasInt.getOwner()); + + assertTrue(AliasInt.getScope() instanceof ICPPTemplateScope); + } + + // template + // struct A { + // template + // struct rebind { + // typedef A other; + // }; + // }; + // + // template + // struct B { + // typedef typename T::template rebind::other type1; + // }; + // + // template + // struct C { + // template + // using rebind2 = typename B::type1; + // }; + // + // template + // struct D : C { + // typedef int type0; + // + // template + // struct rebind { + // typedef typename C::template rebind2 other2; + // }; + // }; + // + // template + // struct E { + // typedef typename D::template rebind::other2 type2; + // typedef D type3; + // typedef typename type3::type0 type; + // }; + // + // void f(int x); + // + // void test(E>::type v) { + // f(v); + // } + public void testAliasTemplate_395026() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java index f031afca0a5..54ee449ebb2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java @@ -425,4 +425,11 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest { parseGCC(code); parseGPP(code); } + + // __float128 f; + public void test__float128() throws Exception { + String code= getAboveComment(); + parseGCC(code); + parseGPP(code); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 8c00a830dd1..691fee0e752 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -2046,4 +2046,19 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public void testMemberOfTemplateTemplateParameter_Bug381824() throws Exception { checkBindings(); } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S; + + // void foo() { + // TAlias myA; + // myA.t = 42; + // } + public void testAliasTemplate() throws Exception { + checkBindings(); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java index 52c117f25ba..a96517f71b0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java @@ -7,6 +7,7 @@ * * Contributors: * Andrew Ferguson (Symbian) - Initial implementation + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.internal.pdom.tests; @@ -21,10 +22,16 @@ import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; +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.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.index.IndexFilter; @@ -34,7 +41,9 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.CCoreInternals; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; @@ -316,6 +325,245 @@ public class CPPClassTemplateTests extends PDOMTestBase { } } + // template + // struct S { + // xT x; + // }; + // template + // using A = S; + public void testSimpleAliasDefinition() throws Exception { + assertDeclarationCount(pdom, "A", 1); + IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm()); + assertEquals(1, bindingA.length); + assertTrue(bindingA[0] instanceof ICPPAliasTemplate); + ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0]; + ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters(); + assertEquals(1, aliasParameters.length); + + assertTrue(aliasParameters[0] instanceof ICPPTemplateTypeParameter); + ICPPTemplateTypeParameter templateParameterAT= (ICPPTemplateTypeParameter) aliasParameters[0]; + assertEquals("aT", templateParameterAT.getName()); + assertNull(templateParameterAT.getDefault()); + assertEquals(0, templateParameterAT.getTemplateNestingLevel()); + + assertDeclarationCount(pdom, "S", 1); + IIndexFragmentBinding[] bindingS= pdom.findBindings(new char[][] {{'S'}}, IndexFilter.ALL_DECLARED, npm()); + IType aliasedType = aliasA.getType(); + assertTrue(aliasedType instanceof ICPPDeferredClassInstance); + ICPPDeferredClassInstance deferredClassInstanceS= (ICPPDeferredClassInstance) aliasedType; + assertEquals(1, bindingA.length); + assertEquals(bindingS[0], deferredClassInstanceS.getSpecializedBinding()); + } + + // struct D { + // }; + // template + // struct S { + // xT x; + // }; + // template + // using A = S; + public void testSimpleAliasDefinitionDefaultTemplateArgument() throws Exception { + assertDeclarationCount(pdom, "A", 1); + IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm()); + assertEquals(1, bindingA.length); + assertTrue(bindingA[0] instanceof ICPPAliasTemplate); + ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0]; + ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters(); + assertEquals(2, aliasParameters.length); + + assertTrue(aliasParameters[0] instanceof ICPPTemplateTypeParameter); + ICPPTemplateTypeParameter templateParameterAT1= (ICPPTemplateTypeParameter) aliasParameters[0]; + assertEquals("aT1", templateParameterAT1.getName()); + assertNull(templateParameterAT1.getDefault()); + assertEquals(0, templateParameterAT1.getTemplateNestingLevel()); + + assertTrue(aliasParameters[1] instanceof ICPPTemplateTypeParameter); + ICPPTemplateTypeParameter templateParameterAT2= (ICPPTemplateTypeParameter) aliasParameters[1]; + assertEquals("aT2", templateParameterAT2.getName()); + IType aT2DefaultArgument = templateParameterAT2.getDefault(); + assertNotNull(aT2DefaultArgument); + assertDeclarationCount(pdom, "D", 1); + IIndexFragmentBinding[] bindingD= pdom.findBindings(new char[][] {{'D'}}, IndexFilter.ALL_DECLARED, npm()); + assertEquals(1, bindingD.length); + assertTrue(bindingD[0] instanceof IType); + assertTrue(((IType)bindingD[0]).isSameType(aT2DefaultArgument)); + assertEquals(0, templateParameterAT2.getTemplateNestingLevel()); + + assertDeclarationCount(pdom, "S", 1); + IIndexFragmentBinding[] bindingS= pdom.findBindings(new char[][] {{'S'}}, IndexFilter.ALL_DECLARED, npm()); + IType aliasedType = aliasA.getType(); + assertTrue(aliasedType instanceof ICPPDeferredClassInstance); + ICPPDeferredClassInstance deferredClassInstanceS= (ICPPDeferredClassInstance) aliasedType; + assertEquals(1, bindingS.length); + assertEquals(bindingS[0], deferredClassInstanceS.getSpecializedBinding()); + } + + // template + // struct S { + // xT x; + // }; + // template + // using A = S; + public void testSimpleAliasDefinitionValueTemplateArguments() throws Exception { + assertDeclarationCount(pdom, "A", 1); + IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm()); + assertEquals(1, bindingA.length); + assertTrue(bindingA[0] instanceof ICPPAliasTemplate); + ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0]; + ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters(); + assertEquals(2, aliasParameters.length); + + assertTrue(aliasParameters[0] instanceof ICPPTemplateNonTypeParameter); + ICPPTemplateNonTypeParameter templateParameterAT1= (ICPPTemplateNonTypeParameter) aliasParameters[0]; + assertEquals("aT1", templateParameterAT1.getName()); + assertNull(templateParameterAT1.getDefaultValue()); + assertEquals(0, templateParameterAT1.getTemplateNestingLevel()); + + assertTrue(aliasParameters[1] instanceof ICPPTemplateNonTypeParameter); + ICPPTemplateNonTypeParameter templateParameterAT2= (ICPPTemplateNonTypeParameter) aliasParameters[1]; + assertEquals("aT2", templateParameterAT2.getName()); + ICPPTemplateArgument aT2DefaultArgument = templateParameterAT2.getDefaultValue(); + assertNotNull(aT2DefaultArgument); + assertTrue(new CPPBasicType(IBasicType.Kind.eInt, 0).isSameType(aT2DefaultArgument.getTypeOfNonTypeValue())); + assertEquals(5, aT2DefaultArgument.getNonTypeValue().numericalValue().longValue()); + assertEquals(0, templateParameterAT2.getTemplateNestingLevel()); + + assertDeclarationCount(pdom, "S", 1); + IIndexFragmentBinding[] bindingS= pdom.findBindings(new char[][] {{'S'}}, IndexFilter.ALL_DECLARED, npm()); + IType aliasedType = aliasA.getType(); + assertTrue(aliasedType instanceof ICPPDeferredClassInstance); + ICPPDeferredClassInstance deferredClassInstanceS= (ICPPDeferredClassInstance) aliasedType; + assertEquals(1, bindingS.length); + assertEquals(bindingS[0], deferredClassInstanceS.getSpecializedBinding()); + } + + // template + // struct S { + // T t; + // }; + // template class TT> + // using A = S; + public void testSimpleAliasTemplateParameter() throws Exception { + assertDeclarationCount(pdom, "A", 1); + IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm()); + assertEquals(1, bindingA.length); + assertTrue(bindingA[0] instanceof ICPPAliasTemplate); + ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0]; + ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters(); + assertEquals(1, aliasParameters.length); + + assertTrue(aliasParameters[0] instanceof ICPPTemplateTemplateParameter); + ICPPTemplateTemplateParameter templateParameterTT= (ICPPTemplateTemplateParameter) aliasParameters[0]; + assertEquals("TT", templateParameterTT.getName()); + assertNull(templateParameterTT.getDefaultValue()); + assertEquals(0, templateParameterTT.getTemplateNestingLevel()); + } + + // struct B{}; + // template + // struct S { + // xT x; + // }; + // template + // using A = S; + // A aB; + // S sB; + public void testSimpleAliasReference() throws Exception { + assertDeclarationCount(pdom, "A", 1); + IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm()); + assertEquals(1, bindingA.length); + assertTrue(bindingA[0] instanceof ICPPAliasTemplate); + ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0]; + ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters(); + assertEquals(1, aliasParameters.length); + + assertReferenceCount(pdom, "S", 2); + assertReferenceCount(pdom, "A", 1); + assertDeclarationCount(pdom, "aB", 1); + assertDeclarationCount(pdom, "sB", 1); + + IIndexFragmentBinding[] bindingVarSB= pdom.findBindings(new char[][] {"sB".toCharArray()}, IndexFilter.ALL, npm()); + assertEquals(1, bindingVarSB.length); + assertTrue(bindingVarSB[0] instanceof ICPPVariable); + ICPPVariable variableSB = (ICPPVariable) bindingVarSB[0]; + IType varSBType = variableSB.getType(); + assertTrue(varSBType instanceof ICPPClassSpecialization); + ICPPClassSpecialization templateInstanceSB = (ICPPClassSpecialization) varSBType; + + IIndexFragmentBinding[] bindingVarAB= pdom.findBindings(new char[][] {"aB".toCharArray()}, IndexFilter.ALL, npm()); + assertEquals(1, bindingVarAB.length); + assertTrue(bindingVarAB[0] instanceof ICPPVariable); + ICPPVariable variableAB = (ICPPVariable) bindingVarAB[0]; + IType varABType = variableAB.getType(); + assertTrue(varABType instanceof ICPPAliasTemplateInstance); + ICPPAliasTemplateInstance aliasInstanceAB = (ICPPAliasTemplateInstance) varABType; + assertTrue(varABType.isSameType(templateInstanceSB)); + assertTrue(aliasInstanceAB.getTemplateDefinition().isSameType(aliasA)); + assertEquals("A", aliasInstanceAB.getName()); + } + + // template class CT { + // template using A= T; // nesting level 1 + // A x; + // }; + public void testPDOMNestedAliasDeclarationNestingLevel() throws Exception { + IIndexFragmentBinding[] bindingCT = pdom.findBindings(new char[][] { "CT".toCharArray() }, IndexFilter.ALL_DECLARED, npm()); + assertEquals(1, bindingCT.length); + assertTrue(bindingCT[0] instanceof ICPPClassTemplate); + ICPPClassTemplate templateCT = (ICPPClassTemplate) bindingCT[0]; + + IField[] fields = templateCT.getFields(); + assertEquals(1, fields.length); + IField x = fields[0]; + IType xType = x.getType(); + assertTrue(xType instanceof ICPPAliasTemplateInstance); + + ICPPAliasTemplateInstance aliasInstance = (ICPPAliasTemplateInstance) xType; + ICPPAliasTemplate alias = aliasInstance.getTemplateDefinition(); + ICPPTemplateParameter[] aliasParameters = alias.getTemplateParameters(); + assertEquals(1, aliasParameters.length); + ICPPTemplateParameter aliasParameterT = aliasParameters[0]; + assertEquals(1, aliasParameterT.getTemplateNestingLevel()); + } + + // template class CT; + // template using A= CT; // nesting level 0 + // template class CT { // nesting level 0 + // typedef Alias TYPE; + // }; + public void testPDOMAliasDeclarationNestingLevel() throws Exception { + assertDeclarationCount(pdom, "A", 1); + IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm()); + assertEquals(1, bindingA.length); + assertTrue(bindingA[0] instanceof ICPPAliasTemplate); + ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0]; + ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters(); + assertEquals(1, aliasParameters.length); + + assertTrue(aliasParameters[0] instanceof ICPPTemplateTypeParameter); + ICPPTemplateTypeParameter templateParameterT= (ICPPTemplateTypeParameter) aliasParameters[0]; + assertEquals("T", templateParameterT.getName()); + assertNull(templateParameterT.getDefault()); + assertEquals(0, templateParameterT.getTemplateNestingLevel()); + + assertDeclarationCount(pdom, "CT", 2); + IIndexFragmentBinding[] bindingCT= pdom.findBindings(new char[][] {"CT".toCharArray()}, IndexFilter.ALL_DECLARED, npm()); + assertEquals(1, bindingCT.length); + assertTrue(bindingCT[0] instanceof ICPPClassTemplate); + ICPPClassTemplate templateCT= (ICPPClassTemplate) bindingCT[0]; + ICPPTemplateParameter[] ctParameters= templateCT.getTemplateParameters(); + assertEquals(1, ctParameters.length); + + assertTrue(ctParameters[0] instanceof ICPPTemplateTypeParameter); + ICPPTemplateTypeParameter templateParameterTofCT= (ICPPTemplateTypeParameter) ctParameters[0]; + assertEquals("T", templateParameterTofCT.getName()); + assertNull(templateParameterTofCT.getDefault()); + assertEquals(0, templateParameterTofCT.getTemplateNestingLevel()); + } + + + @Override protected void assertInstance(Object o, Class c) { assertNotNull(o); diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterTemplateTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterTemplateTestSource.awts index 32ff7264c82..7d68787a8a4 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterTemplateTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterTemplateTestSource.awts @@ -10,4 +10,10 @@ void f(T* p) T::template adjust<100>(); } - +//![temp.alias] Template alias declaration +//%CPP +template struct S +{ +}; +template using Alias = S; +Alias sInt; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java index 6eb4359f1ab..c2a0031218a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java @@ -635,6 +635,9 @@ public class ASTStringUtil { case IASTSimpleDeclSpecifier.t_double: buffer.append(Keywords.DOUBLE).append(' '); break; + case IASTSimpleDeclSpecifier.t_float128: + buffer.append(GCCKeywords.cp__float128).append(' '); + break; case IASTSimpleDeclSpecifier.t_bool: if (simpleDeclSpec instanceof ICASTSimpleDeclSpecifier) { buffer.append(Keywords.cBOOL).append(' '); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java index 8b367ba9017..d5163ef7505 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java @@ -784,6 +784,14 @@ public class ASTSignatureUtil { result.append(GCCKeywords.__INT128); needSpace = true; break; + case IASTSimpleDeclSpecifier.t_float128: + if (needSpace) { + result.append(SPACE); + needSpace = false; + } + result.append(GCCKeywords.__FLOAT128); + needSpace = true; + break; case IASTSimpleDeclSpecifier.t_void: if (needSpace) { result.append(SPACE); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java index 8562e33e5b4..b2fae8e79c3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java @@ -106,6 +106,12 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier { */ public static final int t_int128 = 13; + /** + * __float128 i; + * @since 5.5 + */ + public static final int t_float128 = 14; + /** * @since 5.1 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java index e13798ce231..86a69376d77 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java @@ -23,7 +23,8 @@ public interface IBasicType extends IType { */ enum Kind { eUnspecified, eVoid, eChar, eWChar, eInt, eFloat, eDouble, - eBoolean, eChar16, eChar32, /** @since 5.4 */ eNullPtr, /** @since 5.5 */ eInt128 + eBoolean, eChar16, eChar32, /** @since 5.4 */ eNullPtr, + /** @since 5.5 */ eInt128, /** @since 5.5 */ eFloat128 } /** @since 5.2 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAliasDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAliasDeclaration.java new file mode 100644 index 00000000000..f8ab21dfab8 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAliasDeclaration.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.ast.cpp; + +import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; +import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNameOwner; + +/** + * Represents a C++ alias declaration. + * e.g. struct Type {}; using Alias = Type; + * @since 5.5 + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICPPASTAliasDeclaration extends IASTDeclaration, IASTNameOwner { + public static final ICPPASTAliasDeclaration[] EMPTY_ALIAS_DECLARATION_ARRAY = {}; + + /** + * ALIAS_NAME is the name that is brought into the local scope. + */ + public static final ASTNodeProperty ALIAS_NAME = new ASTNodeProperty( + "ICPPASTAliasDeclaration.ALIAS_NAME - Introduced alias name"); //$NON-NLS-1$ + + /** + * MAPPING_TYPE represents the pre-existing type id which + * the new symbol aliases. + */ + public static final ASTNodeProperty TARGET_TYPEID = new ASTNodeProperty( + "ICPPASTAliasDeclaration.TARGET_TYPEID - Pre-existing type ID the new symbol aliases"); //$NON-NLS-1$ + + /** + * Returns the alias name. + * + * @return IASTName + */ + public IASTName getAlias(); + + /** + * Sets the alias name. + * + * @param aliasName IASTName + */ + public void setAlias(IASTName aliasName); + + /** + * Returns the mapping type id. + * + * @return ICPPASTTypeId + */ + public ICPPASTTypeId getMappingTypeId(); + + /** + * Sets the mapping type id. + * + * @param mappingTypeId ICPPASTTypeId + */ + public void setMappingTypeId(ICPPASTTypeId mappingTypeId); + + @Override + public ICPPASTAliasDeclaration copy(); + + @Override + public ICPPASTAliasDeclaration copy(CopyStyle style); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeId.java index cab1df9c5ef..e26f62e256e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeId.java @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Thomas Corbat (IFS) - Added copy methods *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -20,4 +21,15 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; * @since 5.2 */ public interface ICPPASTTypeId extends IASTTypeId, ICPPASTPackExpandable { + /** + * @since 5.5 + */ + @Override + public ICPPASTTypeId copy(); + + /** + * @since 5.5 + */ + @Override + public ICPPASTTypeId copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDirective.java index 6d96e99672f..9f9c639547a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDirective.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDirective.java @@ -24,7 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTUsingDirective extends IASTDeclaration, IASTNameOwner, IASTAttributeOwner { - public static final ICPPASTUsingDirective[] EMPTY_USINGDIRECTIVE_ARRAY = new ICPPASTUsingDirective[0]; + public static final ICPPASTUsingDirective[] EMPTY_USINGDIRECTIVE_ARRAY = {}; /** * QUALIFIED_NAME is the name that is brought into local diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java new file mode 100644 index 00000000000..ed1d537cd8a --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.ast.cpp; + +import org.eclipse.cdt.core.dom.ast.IType; + +/** + * Represents an alias template (14.5.7). + * @since 5.5 + */ +public interface ICPPAliasTemplate extends IType, ICPPTemplateDefinition { + /** + * Returns the aliased type. + */ + public IType getType(); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java new file mode 100644 index 00000000000..4c2d7d6d9e8 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.ast.cpp; + +import org.eclipse.cdt.core.dom.ast.ITypedef; + +/** + * Represents an instance of an alias template (14.5.7). + * @since 5.5 + */ +public interface ICPPAliasTemplateInstance extends ITypedef, ICPPBinding { + /** + * Returns the alias template specialized by this instance. + */ + public ICPPAliasTemplate getTemplateDefinition(); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java index 3348938c563..101613b3ba4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java @@ -8,6 +8,7 @@ * Contributors: * Mike Kucera (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -354,4 +355,9 @@ public interface ICPPNodeFactory extends INodeFactory { @Override public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body); + + /** + * @since 5.5 + */ + public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId aliasedType); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java index fc9a3ac3758..4ffd8ac64b3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java @@ -68,6 +68,7 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu addMacro("__builtin_offsetof(T,m)", "((size_t) &((T *)0)->m)"); if (version >= VERSION_4_7) { + addKeyword(GCCKeywords.cp__float128, IGCCToken.t__float128); addKeyword(GCCKeywords.cp__int128, IGCCToken.t__int128); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java index b643cd4652b..ffd4111d06a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java @@ -104,6 +104,7 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu addKeyword(GCCKeywords.cp__is_trivial, IGCCToken.tTT_is_trivial); } if (version >= VERSION_4_7) { + addKeyword(GCCKeywords.cp__float128, IGCCToken.t__float128); addKeyword(GCCKeywords.cp__int128, IGCCToken.t__int128); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java index 765f962c5de..a774647e288 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java @@ -25,6 +25,8 @@ public class GCCKeywords { public static final String __DECLSPEC = "__declspec"; /** @since 5.5 */ public static final String __INT128 = "__int128"; + /** @since 5.5 */ + public static final String __FLOAT128 = "__float128"; public static final char[] cpTYPEOF = TYPEOF.toCharArray(), @@ -69,6 +71,7 @@ public class GCCKeywords { /** @since 5.5 */ public static final char[] + cp__float128= __FLOAT128.toCharArray(), cp__int128= __INT128.toCharArray(), cp__is_literal_type= "__is_literal_type".toCharArray(), cp__is_standard_layout= "__is_standard_layout".toCharArray(), diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java index a1c0f9606c0..a8a5d2498f9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java @@ -45,5 +45,6 @@ public interface IGCCToken extends IToken { /** @since 5.5 */ int tTT_is_standard_layout= FIRST_RESERVED_IGCCToken + 23; /** @since 5.5 */ int tTT_is_trivial= FIRST_RESERVED_IGCCToken + 24; - /** @since 5.5 */ int t__int128 = FIRST_RESERVED_IGCCToken + 25; + /** @since 5.5 */ int t__int128= FIRST_RESERVED_IGCCToken + 25; + /** @since 5.5 */ int t__float128= FIRST_RESERVED_IGCCToken + 26; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index cc8f38428db..05511bf2379 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -2591,12 +2591,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { case IToken.t_short: case IToken.t_int: case IToken.t_long: - case IGCCToken.t__int128: case IToken.t_float: case IToken.t_double: case IToken.t__Bool: case IToken.t__Complex: case IToken.t__Imaginary: + case IGCCToken.t__int128: + case IGCCToken.t__float128: case IToken.t_signed: case IToken.t_unsigned: case IToken.t_decltype: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java index 8b465ba06c9..d3c7b188e17 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Thomas Corbat *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -34,6 +35,7 @@ public interface ITypeMarshalBuffer { final static byte UNKNOWN_MEMBER= 12; final static byte UNKNOWN_MEMBER_CLASS_INSTANCE= 13; final static byte DEFERRED_CLASS_INSTANCE= 14; + final static byte ALIAS_TEMPLATE = 15; final static byte EVAL_BINARY= 1, diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java index d04bacd3eb6..a084775601e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java @@ -73,6 +73,8 @@ public class SizeofCalculator { public final SizeAndAlignment sizeof_complex_double; public final SizeAndAlignment sizeof_long_double; public final SizeAndAlignment sizeof_complex_long_double; + public final SizeAndAlignment sizeof_float128; + public final SizeAndAlignment sizeof_complex_float128; private final IASTTranslationUnit ast; @@ -135,6 +137,8 @@ public class SizeofCalculator { sizeof_complex_double = getSizeOfPair(sizeof_double); sizeof_long_double = getSize(sizeofMacros, "__SIZEOF_LONG_DOUBLE__", maxAlignment); //$NON-NLS-1$ sizeof_complex_long_double = getSizeOfPair(sizeof_long_double); + sizeof_float128 = size_16; // GCC does not define __SIZEOF_FLOAT128__ + sizeof_complex_float128 = getSizeOfPair(sizeof_float128); } private SizeofCalculator() { @@ -156,6 +160,8 @@ public class SizeofCalculator { sizeof_complex_double = null; sizeof_long_double = null; sizeof_complex_long_double = null; + sizeof_float128 = size_16; + sizeof_complex_float128 = getSizeOfPair(sizeof_float128); ast = null; } @@ -215,6 +221,8 @@ public class SizeofCalculator { return type.isComplex() ? (type.isLong() ? sizeof_long_double : sizeof_double) : (type.isLong() ? sizeof_complex_long_double : sizeof_complex_double); + case eFloat128: + return type.isComplex() ? sizeof_complex_float128 : sizeof_float128; case eWChar: return sizeof_wchar_t; case eChar16: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java index f2cf88daf27..02165d095a4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) - * Markus Schorn (Wind River Systems) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -19,17 +19,16 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; -public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements ICASTSimpleDeclSpecifier, - IASTAmbiguityParent { - +public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier + implements ICASTSimpleDeclSpecifier, IASTAmbiguityParent { private int simpleType; private boolean isSigned; private boolean isUnsigned; private boolean isShort; private boolean isLong; private boolean longlong; - private boolean complex=false; - private boolean imaginary=false; + private boolean complex; + private boolean imaginary; private IASTExpression fDeclTypeExpression; @Override @@ -110,6 +109,8 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC return t_double; case eFloat: return t_float; + case eFloat128: + return t_float; case eInt: return t_int; case eInt128: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java index 3409058e745..bd3d0b23c36 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2005, 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) 2005, 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: - * Devin Steffler (IBM Rational Software) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Contributors: + * Devin Steffler (IBM Rational Software) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -24,8 +24,8 @@ import org.eclipse.core.runtime.CoreException; public class CBasicType implements ICBasicType, ISerializableType { private final Kind fKind; - private int fModifiers = 0; - private IASTExpression value = null; + private int fModifiers; + private IASTExpression value; public CBasicType(Kind kind, int modifiers, IASTExpression value) { if (kind == Kind.eUnspecified) { @@ -69,6 +69,8 @@ public class CBasicType implements ICBasicType, ISerializableType { return Kind.eDouble; case IASTSimpleDeclSpecifier.t_float: return Kind.eFloat; + case IASTSimpleDeclSpecifier.t_float128: + return Kind.eFloat128; case IASTSimpleDeclSpecifier.t_int: return Kind.eInt; case IASTSimpleDeclSpecifier.t_int128: @@ -122,16 +124,16 @@ public class CBasicType implements ICBasicType, ISerializableType { if (obj instanceof ITypedef) return obj.isSameType(this); - if (!(obj instanceof ICBasicType)) return false; + if (!(obj instanceof ICBasicType)) + return false; ICBasicType cObj = (ICBasicType)obj; - if (fKind != cObj.getKind()) { + if (fKind != cObj.getKind()) return false; - } if (fKind == Kind.eInt) { - //signed int and int are equivalent + // Signed int and int are equivalent return (fModifiers & ~IS_SIGNED) == (cObj.getModifiers() & ~IS_SIGNED); } else { return (fModifiers == cObj.getModifiers()); @@ -144,7 +146,7 @@ public class CBasicType implements ICBasicType, ISerializableType { try { t = (IType) super.clone(); } catch (CloneNotSupportedException e) { - //not going to happen + // Not going to happen } return t; } @@ -155,17 +157,11 @@ public class CBasicType implements ICBasicType, ISerializableType { return value; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.c.ICBasicType#isComplex() - */ @Override public boolean isComplex() { return (fModifiers & IS_COMPLEX) != 0; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.c.ICBasicType#isImaginary() - */ @Override public boolean isImaginary() { return (fModifiers & IS_IMAGINARY) != 0; @@ -220,6 +216,8 @@ public class CBasicType implements ICBasicType, ISerializableType { case eUnspecified: return t_unspecified; case eNullPtr: + case eInt128: + case eFloat128: // Null pointer type cannot be expressed wit ha simple decl specifier. break; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index 7aa0db02fd8..d74fefd9ea1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -1030,6 +1030,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { encounteredRawType= true; endOffset= consume().getEndOffset(); break; + case IGCCToken.t__float128: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_float128; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; case IToken.t_signed: if (encounteredTypename) break declSpecifiers; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAliasDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAliasDeclaration.java new file mode 100644 index 00000000000..a1cbff32b7a --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAliasDeclaration.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp; + +import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId; +import org.eclipse.cdt.internal.core.dom.parser.ASTNode; + +public class CPPASTAliasDeclaration extends ASTNode implements ICPPASTAliasDeclaration { + private IASTName aliasName; + private ICPPASTTypeId mappingTypeId; + + public CPPASTAliasDeclaration(IASTName aliasName, ICPPASTTypeId mappingTypeId){ + setAlias(aliasName); + setMappingTypeId(mappingTypeId); + } + + @Override + public int getRoleForName(IASTName name) { + if (aliasName == name) return r_definition; + if (mappingTypeId == name) return r_reference; + return r_unclear; + } + + @Override + public IASTName getAlias() { + return aliasName; + } + + @Override + public void setAlias(IASTName aliasName) { + assertNotFrozen(); + this.aliasName = aliasName; + if (aliasName != null) { + aliasName.setParent(this); + aliasName.setPropertyInParent(ALIAS_NAME); + } + } + + @Override + public ICPPASTTypeId getMappingTypeId() { + return mappingTypeId; + } + + @Override + public void setMappingTypeId(ICPPASTTypeId mappingTypeId) { + assertNotFrozen(); + this.mappingTypeId = mappingTypeId; + if (mappingTypeId != null) { + mappingTypeId.setParent(this); + mappingTypeId.setPropertyInParent(TARGET_TYPEID); + } + } + + @Override + public ICPPASTAliasDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + 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; + } + + @Override + public boolean accept(ASTVisitor action) { + if (action.shouldVisitDeclarations) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; + } + } + + if (aliasName != null && !aliasName.accept(action)) return false; + if (mappingTypeId != null && !mappingTypeId.accept(action)) return false; + + if (action.shouldVisitDeclarations) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; + } + } + return true; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java index 6c7333ffc2c..809a4b283fc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java @@ -90,6 +90,8 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier return t_double; case eFloat: return t_float; + case eFloat128: + return t_float128; case eInt: return t_int; case eInt128: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java new file mode 100644 index 00000000000..4d8257a99bf --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp; + +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.IASTName; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.internal.core.dom.Linkage; +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 { + private final IASTName aliasName; + private final IType aliasedType; + private ICPPTemplateParameter[] templateParameters; + + public CPPAliasTemplate(IASTName aliasName, IType aliasedType) { + this.aliasName = aliasName; + this.aliasedType = aliasedType; + aliasName.setBinding(this); + } + + @Override + public IType getType() { + return aliasedType; + } + + @Override + public String getName() { + return new String(getNameCharArray()); + } + + @Override + public char[] getNameCharArray() { + return aliasName.getSimpleID(); + } + + @Override + public ILinkage getLinkage() { + return Linkage.CPP_LINKAGE; + } + + @Override + public IBinding getOwner() { + return CPPVisitor.findDeclarationOwner(aliasName, true); + } + + @Override + public IScope getScope() throws DOMException { + return CPPVisitor.getContainingScope(aliasName.getParent()); + } + + @Override + public boolean isSameType(IType type) { + if (type == null) { + return false; + } + IType aliasedType = getType(); + return type.isSameType(aliasedType); + } + + @Override + public Object clone() { + IType t = null; + try { + t = (IType) super.clone(); + } catch (CloneNotSupportedException e) { + // Not going to happen + } + return t; + } + + @Override + public String[] getQualifiedName() throws DOMException { + return CPPVisitor.getQualifiedName(this); + } + + @Override + public char[][] getQualifiedNameCharArray() throws DOMException { + return CPPVisitor.getQualifiedNameCharArray(this); + } + + @Override + public boolean isGloballyQualified() throws DOMException { + return true; + } + + @Override + public ICPPTemplateParameter[] getTemplateParameters() { + if (templateParameters == null) { + ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(aliasName); + if (template == null) + return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY; + ICPPASTTemplateParameter[] params = template.getTemplateParameters(); + IBinding p = null; + ICPPTemplateParameter[] result = null; + for (ICPPASTTemplateParameter param : params) { + p= CPPTemplates.getTemplateParameterName(param).resolveBinding(); + if (p instanceof ICPPTemplateParameter) { + result = ArrayUtil.append(ICPPTemplateParameter.class, result, (ICPPTemplateParameter) p); + } + } + templateParameters = ArrayUtil.trim(ICPPTemplateParameter.class, result); + } + return templateParameters; + } + + @Override + public String toString() { + return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$ + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java new file mode 100644 index 00000000000..4435b4020dc --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp; + +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.IBinding; +import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; +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.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 { + private final char[] name; + private final IType aliasedType; + private final ICPPAliasTemplate aliasTemplate; + + public CPPAliasTemplateInstance(char[] name, IType aliasedType, ICPPAliasTemplate aliasTemplate) { + this.name = name; + this.aliasedType = aliasedType; + this.aliasTemplate = aliasTemplate; + } + + @Override + public ICPPAliasTemplate getTemplateDefinition() { + return aliasTemplate; + } + + @Override + public boolean isSameType(IType other) { + if (other == aliasedType) + return true; + if (aliasedType != null) { + return aliasedType.isSameType(other); + } + return false; + } + + @Override + public IType getType() { + return aliasedType; + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + } + return null; + } + + @Override + public String getName() { + return new String(getNameCharArray()); + } + + @Override + public char[] getNameCharArray() { + if (name != null) { + return name; + } + return new char[0]; + } + + @Override + public ILinkage getLinkage() { + return Linkage.CPP_LINKAGE; + } + + @Override + public IBinding getOwner() { + if (aliasTemplate != null) { + return aliasTemplate.getOwner(); + } + return null; + } + + @Override + public IScope getScope() throws DOMException { + if (aliasTemplate != null) { + return aliasTemplate.getScope(); + } + return null; + } + + @Override + public void marshal(ITypeMarshalBuffer buffer) throws CoreException { + int firstByte = ITypeMarshalBuffer.ALIAS_TEMPLATE; + buffer.putByte((byte) firstByte); + buffer.putCharArray(name); + buffer.marshalType(aliasedType); + buffer.marshalBinding(aliasTemplate); + } + + public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { + char[] name = buffer.getCharArray(); + IType unmarshalledAliasedTypeInstance = buffer.unmarshalType(); + ICPPAliasTemplate unmarshalledAlias = (ICPPAliasTemplate)buffer.unmarshalBinding(); + return new CPPAliasTemplateInstance(name, unmarshalledAliasedTypeInstance, unmarshalledAlias); + } + + @Override + public String toString() { + return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$ + } + + @Override + public String[] getQualifiedName() { + return CPPVisitor.getQualifiedName(this); + } + + @Override + public char[][] getQualifiedNameCharArray() { + return CPPVisitor.getQualifiedNameCharArray(this); + } + + @Override + public boolean isGloballyQualified() throws DOMException { + return ((ICPPBinding) aliasTemplate).isGloballyQualified(); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java index 0dd4aba9b71..12a06267a49 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java @@ -100,6 +100,8 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType { return Kind.eDouble; case IASTSimpleDeclSpecifier.t_float: return Kind.eFloat; + case IASTSimpleDeclSpecifier.t_float128: + return Kind.eFloat128; case IASTSimpleDeclSpecifier.t_int: return Kind.eInt; case IASTSimpleDeclSpecifier.t_int128: @@ -275,6 +277,8 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType { case eUnspecified: return t_unspecified; case eNullPtr: + case eInt128: + case eFloat128: // Null pointer type cannot be expressed wit ha simple decl specifier. break; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java index 575873a4e67..fedcacd8a32 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java @@ -51,6 +51,7 @@ import org.eclipse.cdt.core.dom.ast.IASTToken; import org.eclipse.cdt.core.dom.ast.IASTTokenList; import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeIdInitializerExpression; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression; @@ -747,4 +748,9 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory { public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) { return new CPPASTWhileStatement(condition, body); } + + @Override + public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId mappingTypeId) { + return new CPPASTAliasDeclaration(aliasName, mappingTypeId); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index a23acd37a51..b7082f7aa78 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -66,6 +66,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IASTWhileStatement; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; +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.ICPPASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture; @@ -1891,7 +1892,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { default: throw backtrack; } - ICPPASTUsingDirective astUD = nodeFactory.newUsingDirective(name); if (attributes != null) { for (IASTAttribute attribute : attributes) { @@ -1902,10 +1902,33 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return astUD; } + if(LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tASSIGN){ + return aliasDeclaration(offset); + + } ICPPASTUsingDeclaration result = usingDeclaration(offset); return result; } + private IASTDeclaration aliasDeclaration(final int offset) throws EndOfFileException, + BacktrackException { + IToken identifierToken = consume(); + IASTName aliasName = buildName(-1, identifierToken); + + consume(); + + ICPPASTTypeId aliasedType = typeId(DeclarationOptions.TYPEID); + + if(LT(1) != IToken.tSEMI){ + throw backtrack; + } + int endOffset = consume().getEndOffset(); + + ICPPASTAliasDeclaration aliasDeclaration = nodeFactory.newAliasDeclaration(aliasName, aliasedType); + setRange(aliasDeclaration, offset, endOffset); + return aliasDeclaration; + } + private ICPPASTUsingDeclaration usingDeclaration(final int offset) throws EndOfFileException, BacktrackException { boolean typeName = false; if (LT(1) == IToken.t_typename) { @@ -2851,6 +2874,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { encounteredRawType= true; endOffset= consume().getEndOffset(); break; + case IGCCToken.t__float128: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_float128; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; case IToken.t_void: if (encounteredTypename) break declSpecifiers; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java index 4032094ee4b..4c5ff020493 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java @@ -586,22 +586,24 @@ class BuiltinOperators { return type instanceof ICPPPointerToMemberType; } - private boolean isBoolean(IType type) { + private static boolean isBoolean(IType type) { return type instanceof IBasicType && ((IBasicType) type).getKind() == Kind.eBoolean; } - private boolean isFloatingPoint(IType type) { + private static boolean isFloatingPoint(IType type) { if (type instanceof IBasicType) { IBasicType.Kind kind= ((IBasicType) type).getKind(); switch (kind) { case eDouble: case eFloat: + case eFloat128: return true; case eBoolean: case eChar: case eChar16: case eChar32: case eInt: + case eInt128: case eWChar: case eUnspecified: case eVoid: @@ -612,7 +614,7 @@ class BuiltinOperators { return false; } - private boolean isArithmetic(IType type) { + private static boolean isArithmetic(IType type) { if (type instanceof IBasicType) { IBasicType.Kind kind= ((IBasicType) type).getKind(); switch (kind) { @@ -622,7 +624,9 @@ class BuiltinOperators { case eChar32: case eDouble: case eFloat: + case eFloat128: case eInt: + case eInt128: case eWChar: return true; case eUnspecified: @@ -634,7 +638,7 @@ class BuiltinOperators { return false; } - private boolean isIntegral(IType type) { + private static boolean isIntegral(IType type) { if (type instanceof IBasicType) { IBasicType.Kind kind= ((IBasicType) type).getKind(); switch (kind) { @@ -643,10 +647,12 @@ class BuiltinOperators { case eChar16: case eChar32: case eInt: + case eInt128: case eWChar: return true; case eDouble: case eFloat: + case eFloat128: case eUnspecified: case eVoid: case eNullPtr: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 98bcf4830b8..3f4d58c7b84 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -12,6 +12,7 @@ * Andrew Ferguson (Symbian) * Sergey Prigogin (Google) * Mike Kucera (IBM) + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; @@ -92,6 +93,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.IVariable; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; @@ -1668,6 +1670,9 @@ public class CPPSemantics { } else if (declaration instanceof ICPPASTNamespaceAlias) { IASTName alias = ((ICPPASTNamespaceAlias) declaration).getAlias(); ASTInternal.addName(scope, alias); + } else if (declaration instanceof ICPPASTAliasDeclaration) { + IASTName alias = ((ICPPASTAliasDeclaration) declaration).getAlias(); + ASTInternal.addName(scope, alias); } else if (declaration instanceof IASTFunctionDefinition) { IASTFunctionDefinition functionDef = (IASTFunctionDefinition) declaration; final IASTDeclSpecifier declSpec = functionDef.getDeclSpecifier(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 276c7903673..465d3a0e4ef 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -10,6 +10,7 @@ * Bryan Wilkinson (QNX) * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; @@ -66,6 +67,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; @@ -103,6 +105,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; 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.CPPASTName; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplateInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecialization; @@ -393,7 +396,7 @@ public class CPPTemplates { return instance; } - private static ICPPTemplateArgument[] addDefaultArguments(ICPPClassTemplate template, + private static ICPPTemplateArgument[] addDefaultArguments(ICPPTemplateDefinition template, ICPPTemplateArgument[] arguments, IASTNode point) throws DOMException { if (template instanceof ICPPClassTemplatePartialSpecialization) return arguments; @@ -642,17 +645,30 @@ public class CPPTemplates { } } try { - // Class template instance. IBinding result= null; IASTName templateName = id.getTemplateName(); IBinding template = templateName.resolvePreBinding(); + // Alias Template. + if (template instanceof ICPPAliasTemplate) { + ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) template; + IType aliasedType = aliasTemplate.getType(); + ICPPTemplateArgument[] args = createTemplateArgumentArray(id); + args = addDefaultArguments(aliasTemplate, args, id); + ICPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args); + IBinding owner = template.getOwner(); + ICPPClassSpecialization within = getSpecializationContext(owner); + IType instantiatedType = instantiateType(aliasedType, parameterMap, -1, within, id); + return new CPPAliasTemplateInstance(id.toCharArray(), instantiatedType, aliasTemplate); + } + + // Class template. if (template instanceof ICPPConstructor) { template= template.getOwner(); } if (template instanceof ICPPUnknownMemberClass) { - IType owner= ((ICPPUnknownMemberClass)template).getOwnerType(); + IType owner= ((ICPPUnknownMemberClass) template).getOwnerType(); ICPPTemplateArgument[] args= createTemplateArgumentArray(id); args= SemanticUtil.getSimplifiedArguments(args); return new CPPUnknownClassInstance(owner, id.getSimpleID(), args); @@ -716,8 +732,9 @@ public class CPPTemplates { if (parentOfName instanceof ICPPASTElaboratedTypeSpecifier || parentOfName instanceof ICPPASTCompositeTypeSpecifier || parentOfName instanceof ICPPASTNamedTypeSpecifier || - parentOfName instanceof ICPPASTBaseSpecifier) + parentOfName instanceof ICPPASTBaseSpecifier) { return true; + } if (parentOfName instanceof IASTDeclarator) { IASTDeclarator rel= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) parentOfName); @@ -726,7 +743,6 @@ public class CPPTemplates { return false; } - public static ICPPTemplateInstance createInstance(IBinding owner, ICPPTemplateDefinition template, CPPTemplateParameterMap tpMap, ICPPTemplateArgument[] args, IASTNode point) { if (owner instanceof ICPPSpecialization) { @@ -811,6 +827,10 @@ public class CPPTemplates { } else if (decl instanceof ITypedef) { IType type= instantiateType(((ITypedef) decl).getType(), tpMap, -1, getSpecializationContext(owner), point); spec = new CPPTypedefSpecialization(decl, owner, tpMap, type); + } 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); } 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; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index 31ad69b6196..71937b1296e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -10,6 +10,7 @@ * Markus Schorn (Wind River Systems) * Andrew Ferguson (Symbian) * Sergey Prigogin (Google) + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; @@ -93,6 +94,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.IVariable; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; @@ -172,6 +174,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTUnaryExpression; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplate; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplate; @@ -654,10 +657,32 @@ public class CPPVisitor extends ASTQueries { binding = new ProblemBinding(alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND); } } - return binding; + } else if (declaration instanceof ICPPASTAliasDeclaration) { + ICPPASTAliasDeclaration alias = (ICPPASTAliasDeclaration) declaration; + ICPPScope scope = (ICPPScope) getContainingScope(declaration); + IBinding binding = scope.getBinding(alias.getAlias(), false); + if (!(binding instanceof ICPPInternalBinding)) { + IType type = createType(alias.getMappingTypeId()); + if (type instanceof IProblemBinding) { + IProblemBinding problem = (IProblemBinding) type; + type = new CPPClassType.CPPClassTypeProblem(problem.getASTNode(), problem.getID(), + alias.getMappingTypeId().getAbstractDeclarator().getName().toCharArray()); + } + if (type != null) { + if (alias.getParent() instanceof ICPPASTTemplateDeclaration) { + binding = new CPPAliasTemplate(alias.getAlias(), type); + } else { + CPPTypedef typedef = new CPPTypedef(alias.getAlias()); + typedef.setType(type); + binding = typedef; + } + } else { + binding = new ProblemBinding(alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND); + } + } + return binding; } - return null; } @@ -1766,7 +1791,7 @@ public class CPPVisitor extends ASTQueries { if (pDtor != null) { pt = createType(pt, pDtor); } - pt= adjustParameterType(pt, forFuncType); + pt= adjustParameterType(pt, forFuncType); if (pDtor != null && CPPVisitor.findInnermostDeclarator(pDtor).declaresParameterPack()) { pt= new CPPParameterPackType(pt); @@ -1810,13 +1835,12 @@ public class CPPVisitor extends ASTQueries { return pTypes; } - /** * Adjusts the parameter type according to 8.3.5-3: * cv-qualifiers are deleted, arrays and function types are converted to pointers. */ static IType adjustParameterType(final IType pt, boolean forFunctionType) { - // bug 239975 + // Bug 239975 IType t= SemanticUtil.getNestedType(pt, TDEF); if (t instanceof IArrayType) { IArrayType at = (IArrayType) t; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java index 267b5c018dd..0707a73c5db 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java @@ -183,7 +183,7 @@ public class Conversions { return cost; } } - // � otherwise, the program is ill-formed. + // otherwise, the program is ill-formed. return Cost.NO_CONVERSION; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java index 2c3cc53bf77..4cbea3195e5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java @@ -336,7 +336,7 @@ public class EvalID extends CPPEvaluation { @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { - int r = fFieldOwner.determinePackSize(tpMap); + int r = fFieldOwner != null ? fFieldOwner.determinePackSize(tpMap) : CPPTemplates.PACK_SIZE_NOT_FOUND; for (ICPPTemplateArgument arg : fTemplateArgs) { r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap)); } @@ -345,6 +345,6 @@ public class EvalID extends CPPEvaluation { @Override public boolean referencesTemplateParameter() { - return fFieldOwner.referencesTemplateParameter(); + return fFieldOwner != null && fFieldOwner.referencesTemplateParameter(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java index df7e77c86cf..f4610043e90 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java @@ -87,6 +87,8 @@ public class DeclSpecWriter extends NodeWriter { return Keywords.FLOAT; case IASTSimpleDeclSpecifier.t_double: return Keywords.DOUBLE; + case IASTSimpleDeclSpecifier.t_float128: + return GCCKeywords.__FLOAT128; case IASTSimpleDeclSpecifier.t_bool: return isCpp ? Keywords.BOOL : Keywords._BOOL; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java index dc15a60bdc3..8776a2a3df9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java @@ -10,6 +10,7 @@ * Institute for Software - initial API and implementation * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; @@ -18,9 +19,11 @@ 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.IASTName; import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; @@ -32,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; @@ -93,6 +97,8 @@ public class DeclarationWriter extends NodeWriter { writeUsingDirective((ICPPASTUsingDirective) declaration); } else if (declaration instanceof ICPPASTVisibilityLabel) { writeVisibilityLabel((ICPPASTVisibilityLabel) declaration); + } else if (declaration instanceof ICPPASTAliasDeclaration) { + writeAliasDeclaration((ICPPASTAliasDeclaration) declaration); } writeTrailingComments(declaration, addNewLine); @@ -104,6 +110,20 @@ public class DeclarationWriter extends NodeWriter { } } + private void writeAliasDeclaration(ICPPASTAliasDeclaration aliasDeclaration) { + scribe.printStringSpace(Keywords.USING); + IASTName alias = aliasDeclaration.getAlias(); + if (alias != null) { + alias.accept(visitor); + } + scribe.print(EQUALS); + ICPPASTTypeId aliasedType = aliasDeclaration.getMappingTypeId(); + if (aliasedType != null) { + aliasedType.accept(visitor); + } + scribe.printSemicolon(); + } + private void writeVisibilityLabel(ICPPASTVisibilityLabel visiblityLabel) { scribe.decrementIndentationLevel(); switch (visiblityLabel.getVisibility()) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java index ac8795b0018..7aab87f9d8d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java @@ -8,6 +8,7 @@ * Contributors: * Andrew Ferguson (Symbian) - Initial implementation * Markus Schorn (Wind River Systems) + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.internal.core.index; @@ -60,4 +61,5 @@ public interface IIndexCPPBindingConstants { int CPP_UNKNOWN_FIELD = IIndexBindingConstants.LAST_CONSTANT + 48; int CPP_USING_DECLARATION_SPECIALIZATION= IIndexBindingConstants.LAST_CONSTANT + 49; int CPP_UNKNOWN_METHOD = IIndexBindingConstants.LAST_CONSTANT + 50; + int CPP_TEMPLATE_ALIAS = IIndexBindingConstants.LAST_CONSTANT + 51; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java index 2c067f2bbab..66d8f36bef8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java @@ -22,6 +22,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.ICPPAliasTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; @@ -129,9 +130,9 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { return new CompositeCPPNamespaceScope(this, namespaces); } throw new CompositingNotImplementedError(rscope.getClass().getName()); - } catch(CoreException ce) { - CCorePlugin.log(ce); - throw new CompositingNotImplementedError(ce.getMessage()); + } catch (CoreException e) { + CCorePlugin.log(e); + throw new CompositingNotImplementedError(e.getMessage()); } } @@ -482,7 +483,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof ICPPFunction) { return new CompositeCPPFunctionInstance(this, (ICPPFunction) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } } else if (binding instanceof ICPPTemplateDefinition) { @@ -499,7 +500,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof ICPPFunctionType) { return new CompositeCPPFunctionTemplateSpecialization(this, (ICPPFunction) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } else { if (binding instanceof ICPPClassType) { @@ -519,10 +520,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof ICPPUsingDeclaration) { return new CompositeCPPUsingDeclarationSpecialization(this, (ICPPUsingDeclaration) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } - } else if(binding instanceof ICPPTemplateParameter) { + } else if (binding instanceof ICPPTemplateParameter) { if (binding instanceof ICPPTemplateTypeParameter) { result = new CompositeCPPTemplateTypeParameter(this, (ICPPTemplateTypeParameter) binding); } else if (binding instanceof ICPPTemplateNonTypeParameter) { @@ -530,7 +531,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof ICPPTemplateTemplateParameter) { result = new CompositeCPPTemplateTemplateParameter(this, (ICPPTemplateTemplateParameter) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } else if (binding instanceof ICPPTemplateDefinition) { if (binding instanceof ICPPClassTemplate) { @@ -542,8 +543,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { return new CompositeCPPMethodTemplate(this, (ICPPMethod) binding); } else if (binding instanceof ICPPFunctionTemplate) { return new CompositeCPPFunctionTemplate(this, (ICPPFunction) binding); + } else if (binding instanceof ICPPAliasTemplate) { + return new CompositeCPPAliasTemplate(this, (ICPPBinding) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } else if (binding instanceof ICPPParameter) { result = new CompositeCPPParameter(this, (ICPPParameter) binding); @@ -569,7 +572,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { return new CompositeCPPUnknownMethod(b, def.getNameCharArray()); } } - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } else if (binding instanceof ICPPClassType) { ICPPClassType def = (ICPPClassType) findOneBinding(binding); result = def == null ? null : new CompositeCPPClassType(this, def); @@ -596,11 +599,11 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof IIndexMacroContainer) { result= new CompositeMacroContainer(this, binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } - } catch(CoreException ce) { - CCorePlugin.log(ce); - throw new CompositingNotImplementedError(ce.getMessage()); + } catch (CoreException e) { + CCorePlugin.log(e); + throw new CompositingNotImplementedError(e.getMessage()); } return result; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPAliasTemplate.java new file mode 100644 index 00000000000..96d7b06a739 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPAliasTemplate.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * 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.index.composite.cpp; + +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; + +class CompositeCPPAliasTemplate extends CompositeCPPBinding implements ICPPAliasTemplate { + public CompositeCPPAliasTemplate(ICompositesFactory cf, ICPPBinding delegate) { + super(cf, delegate); + } + + @Override + public Object clone() { + fail(); return null; + } + + @Override + public IType getType() { + IType type = ((ICPPAliasTemplate) rbinding).getType(); + return cf.getCompositeType(type); + } + + @Override + public boolean isSameType(IType type) { + return ((ICPPAliasTemplate) rbinding).isSameType(type); + } + + @Override + public ICPPTemplateParameter[] getTemplateParameters() { + return TemplateInstanceUtil.convert(cf, ((ICPPAliasTemplate) rbinding).getTemplateParameters()); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeration.java index 50c3a63b530..dbae723aa2f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeration.java @@ -36,7 +36,7 @@ class CompositeCPPEnumeration extends CompositeCPPBinding implements ICPPEnumera @Override public boolean isSameType(IType type) { - return ((IEnumeration)rbinding).isSameType(type); + return ((IEnumeration) rbinding).isSameType(type); } @Override @@ -48,17 +48,17 @@ class CompositeCPPEnumeration extends CompositeCPPBinding implements ICPPEnumera } @Override public long getMinValue() { - return ((IEnumeration)rbinding).getMinValue(); + return ((IEnumeration) rbinding).getMinValue(); } @Override public long getMaxValue() { - return ((IEnumeration)rbinding).getMaxValue(); + return ((IEnumeration) rbinding).getMaxValue(); } @Override public boolean isScoped() { - return ((ICPPEnumeration)rbinding).isScoped(); + return ((ICPPEnumeration) rbinding).isScoped(); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java index 51820cbe782..956951914e4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java @@ -25,13 +25,13 @@ class CompositeCPPTypedef extends CompositeCPPBinding implements ITypedef, IInde @Override public IType getType() { - IType type = ((ITypedef)rbinding).getType(); + IType type = ((ITypedef) rbinding).getType(); return cf.getCompositeType(type); } @Override public boolean isSameType(IType type) { - return ((ITypedef)rbinding).isSameType(type); + return ((ITypedef) rbinding).isSameType(type); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAliasTemplate.java new file mode 100644 index 00000000000..7cf0c3c4971 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAliasTemplate.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.pdom.dom.cpp; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; +import org.eclipse.cdt.internal.core.pdom.db.Database; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; +import org.eclipse.core.runtime.CoreException; + +/** + * PDOM binding for alias template. + */ +class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate { + private static final int ALIASED_TYPE_SIZE = Database.TYPE_SIZE; + private static final int TEMPLATE_PARAMS_SIZE = PDOMCPPTemplateTemplateParameter.RECORD_SIZE; + @SuppressWarnings("hiding") + protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + ALIASED_TYPE_SIZE + TEMPLATE_PARAMS_SIZE; + + private static final int ALIASED_TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE + 0; + private static final int TEMPLATE_PARAMS_OFFSET = ALIASED_TYPE_OFFSET + ALIASED_TYPE_SIZE; + + private volatile IPDOMCPPTemplateParameter[] parameters; + + public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, PDOMNode parent, + ICPPAliasTemplate templateAlias) throws CoreException, DOMException { + super(linkage, parent, templateAlias.getNameCharArray()); + setTemplateParameters(linkage, templateAlias.getTemplateParameters()); + setType(linkage, templateAlias.getType()); + } + + public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, long record) { + super(linkage, record); + } + + private void setTemplateParameters(PDOMCPPLinkage linkage, + final ICPPTemplateParameter[] origParams) throws CoreException, DOMException { + parameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams); + final Database db = getDB(); + long rec= PDOMTemplateParameterArray.putArray(db, parameters); + db.putRecPtr(record + TEMPLATE_PARAMS_OFFSET, rec); + linkage.new ConfigureTemplateParameters(origParams, parameters); + } + + private void setType(PDOMCPPLinkage linkage, IType aliasedType) throws CoreException { + linkage.storeType(record + ALIASED_TYPE_OFFSET, aliasedType); + } + + @Override + public int getNodeType() { + return IIndexCPPBindingConstants.CPP_TEMPLATE_ALIAS; + } + + @Override + public boolean isSameType(IType type) { + if(type == null){ + return false; + } + IType aliasedType = getType(); + return type.isSameType(aliasedType); + } + + @Override + public ICPPTemplateParameter[] getTemplateParameters() { + if (parameters == null) { + try { + Database db = getDB(); + long rec= db.getRecPtr(record + TEMPLATE_PARAMS_OFFSET); + if (rec == 0) { + parameters= IPDOMCPPTemplateParameter.EMPTY_ARRAY; + } else { + parameters= PDOMTemplateParameterArray.getArray(this, rec); + } + } catch (CoreException e) { + CCorePlugin.log(e); + parameters = IPDOMCPPTemplateParameter.EMPTY_ARRAY; + } + } + return parameters; + } + + @Override + public IType getType() { + try { + return getLinkage().loadType(record + ALIASED_TYPE_OFFSET); + } catch (CoreException e) { + CCorePlugin.log(e); + return null; + } + } + + @Override + protected int getRecordSize() { + return RECORD_SIZE; + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + } + return null; + } +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index 0160143f331..920b06a2789 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -10,6 +10,7 @@ * Markus Schorn (Wind River Systems) * Andrew Ferguson (Symbian) * Sergey Prigogin (Google) + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -60,6 +61,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias; 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.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance; 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.ICPPTemplateNonTypeParameter; @@ -86,6 +89,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplateInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMember; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; @@ -409,6 +413,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } } else if (binding instanceof ITypedef) { pdomBinding = new PDOMCPPTypedef(this, parent, (ITypedef) binding); + } else if (binding instanceof ICPPAliasTemplate) { + pdomBinding = new PDOMCPPAliasTemplate(this, parent, (ICPPAliasTemplate) binding); } if (pdomBinding != null) { @@ -601,11 +607,18 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { return CPPENUMERATOR; } else if (binding instanceof ITypedef) { return CPPTYPEDEF; + } else if (binding instanceof ICPPAliasTemplate) { + return CPP_TEMPLATE_ALIAS; } return 0; } + @Override + protected boolean cannotAdapt(final IBinding inputBinding) throws CoreException { + return super.cannotAdapt(inputBinding) || inputBinding instanceof ICPPAliasTemplateInstance; + } + @Override public final PDOMBinding adaptBinding(final IBinding inputBinding, boolean includeLocal) throws CoreException { return adaptBinding(null, inputBinding, includeLocal ? FILE_LOCAL_REC_DUMMY : null); @@ -825,6 +838,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { return new PDOMCPPTypedefSpecialization(this, record); case CPP_USING_DECLARATION_SPECIALIZATION: return new PDOMCPPUsingDeclarationSpecialization(this, record); + case CPP_TEMPLATE_ALIAS: + return new PDOMCPPAliasTemplate(this, record); } assert false : "nodeid= " + nodeType; //$NON-NLS-1$ return null; @@ -1044,6 +1059,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer); case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE: return CPPDeferredClassInstance.unmarshal(getPDOM(), firstByte, buffer); + case ITypeMarshalBuffer.ALIAS_TEMPLATE: + return CPPAliasTemplateInstance.unmarshal(firstByte, buffer); } throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java index 98f8937bfb8..2f493a5fd81 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java @@ -91,10 +91,12 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager { protected int getVarMacroSupplierNum(EnvVarDescriptor var, IVariableContextInfo varMacroInfo) { int varSupplierNum = -1; ICdtVariableSupplier macroSuppliers[] = varMacroInfo.getSuppliers(); - for(int i = 0; i < macroSuppliers.length; i++) { - if (macroSuppliers[i] instanceof EnvironmentVariableSupplier) { - varSupplierNum = i; - break; + if (macroSuppliers != null) { + for(int i = 0; i < macroSuppliers.length; i++) { + if (macroSuppliers[i] instanceof EnvironmentVariableSupplier) { + varSupplierNum = i; + break; + } } } return varSupplierNum;