diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.core/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.core/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.core/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.core/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java 2015-02-11 19:19:10.000000000 +0000 @@ -1031,15 +1031,6 @@ return rc; } - // Method to translate paths to various commands to their remote counter-parts - private IPath getRemotePath(IPath path) { - IRemoteResource remRes = (IRemoteResource) getProject().getAdapter(IRemoteResource.class); - if (remRes != null) { - return RemoteCommandLauncher.makeRemote(path, remRes); - } - return path; - } - // Method to get the Win OS Type to distinguish between Cygwin and MingW private String getWinOSType() { if (winOSType.equals("")) { @@ -1137,11 +1128,7 @@ boolean removePWD = false; removeAllMarkers(project); - - // Convert the command path if we have an absolute path and we are executing this remotely - if (commandPath.isAbsolute()) - commandPath = getRemotePath(commandPath); - + // We want to run the script via the shell command. So, we add the command // script as the first argument and expect "sh" to be on the runtime path. // Any other arguments are placed after the script name. diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.docs/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.docs/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.docs/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.docs/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools-feature/feature.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools-feature/feature.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools-feature/feature.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools-feature/feature.xml 2015-02-11 19:19:10.000000000 +0000 @@ -2,7 +2,7 @@ diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools-feature/p2.inf eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools-feature/p2.inf --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools-feature/p2.inf 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools-feature/p2.inf 2015-02-11 19:19:10.000000000 +0000 @@ -3,6 +3,4 @@ provides.99.namespace=org.eclipse.equinox.p2.iu provides.99.name=org.eclipse.linuxtools.cdt.autotools.feature.group provides.99.version=$version$ -instructions.configure=\ -org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(location:http${#58}//download.eclipse.org/tools/cdt/releases/8.5,type:0,name:CDT,enabled:false); \ -org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(location:http${#58}//download.eclipse.org/tools/cdt/releases/8.5,type:1,name:CDT,enabled:false); + diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools-feature/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools-feature/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools-feature/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools-feature/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,12 +7,12 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml org.eclipse.cdt.features - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT org.eclipse.cdt.autotools eclipse-feature diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.source-feature/feature.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.source-feature/feature.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.source-feature/feature.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.source-feature/feature.xml 2015-02-11 19:19:10.000000000 +0000 @@ -2,7 +2,7 @@ diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.source-feature/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.source-feature/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.source-feature/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.source-feature/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,12 +7,12 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml org.eclipse.cdt.features - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT org.eclipse.cdt.autotools.source eclipse-feature diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.tests/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.tests/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.tests/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.tests/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml @@ -32,7 +32,7 @@ ${tycho-version} true - ${base.ui.test.vmargs} + ${tycho.testArgLine} ${base.ui.test.vmargs} **/AllAutotoolsTests.* diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/configure.ac eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/configure.ac --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/configure.ac 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/configure.ac 2015-02-11 19:19:10.000000000 +0000 @@ -6,6 +6,8 @@ AC_CANONICAL_SYSTEM +AC_CONFIG_MACRO_DIR([m4]) + dnl Initialize automake AM_INIT_AUTOMAKE @@ -15,10 +17,6 @@ dnl Initialize Libtool LT_INIT -dnl Check if Libtool is present -dnl Libtool is used for building share libraries -AC_PROG_LIBTOOL - AC_CONFIG_FILES(Makefile exampleProgram/Makefile $(libName)/Makefile diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/exampleProgram/Makefile.am eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/exampleProgram/Makefile.am --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/exampleProgram/Makefile.am 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/exampleProgram/Makefile.am 2015-02-11 19:19:10.000000000 +0000 @@ -15,11 +15,16 @@ # replaced by '_'. So a.out becomes a_out and the appropriate suffex added. # '_SOURCES' for example. +ACLOCAL_AMFLAGS=-I ../m4 + # Sources for the a.out exampleProgram_SOURCES= exampleProgram.c +# Libraries for a.out +exampleProgram_LDADD = $(top_srcdir)/$(libName)/$(libName).la + # Linker options for a.out -exampleProgram_LDFLAGS = $(top_srcdir)/$(libName)/$(libName).la +exampleProgram_LDFLAGS = -rpath `cd $(top_srcdir);pwd`/$(libName)/.libs # Compiler options for a.out exampleProgram_CPPFLAGS = -I$(top_srcdir)/include diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/Makefile.am eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/Makefile.am --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/Makefile.am 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/Makefile.am 2015-02-11 19:19:10.000000000 +0000 @@ -1 +1,2 @@ SUBDIRS=$(libName) include exampleProgram +ACLOCAL_AMFLAGS=-I m4 diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/template.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/template.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/template.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui/templates/projecttemplates/AutotoolsSharedLibraryProject/template.xml 2015-02-11 19:19:10.000000000 +0000 @@ -52,6 +52,11 @@ + + + + + diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -14,7 +14,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml @@ -33,10 +33,11 @@ false org.eclipse.platform.ide org.eclipse.ui.ide.workbench - ${base.ui.test.vmargs} + ${tycho.testArgLine} ${base.ui.test.vmargs} **/AllTests.* + true org.eclipse.platform.feature.group @@ -47,4 +48,4 @@ - \ No newline at end of file + diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AbstractTest.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AbstractTest.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AbstractTest.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AbstractTest.java 2015-02-11 19:19:10.000000000 +0000 @@ -17,14 +17,15 @@ import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle; import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget; import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.bindings.keys.KeyStroke; import org.eclipse.jface.bindings.keys.ParseException; import org.eclipse.swt.SWT; @@ -52,27 +53,34 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.hamcrest.Matcher; import org.junit.After; +import org.junit.AfterClass; +import org.junit.BeforeClass; public abstract class AbstractTest { + + private static final String PROJECT_NAME = "GnuProject"; + protected static SWTWorkbenchBot bot; protected static String projectName; protected static SWTBotShell mainShell; protected static SWTBotView projectExplorer; + @BeforeClass + public static void initAbstractClass() throws Exception { + AbstractTest.init(PROJECT_NAME); + } + + @AfterClass + public static void afterClass() throws Exception { + AbstractTest.deleteProject(PROJECT_NAME); + } + public static void init(String projectName) throws Exception { SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; + SWTBotPreferences.PLAYBACK_DELAY = 10; bot = new SWTWorkbenchBot(); - mainShell = null; - for (int i = 0, attempts = 100; i < attempts; i++) { - for (SWTBotShell shell : bot.shells()) { - if (shell.getText().contains("Eclipse Platform")) { - mainShell = shell; - shell.setFocus(); - break; - } - } - } - assertNotNull(mainShell); + bot.sleep(5000); + mainShell = getMainShell(); // Close the Welcome view if it exists try { bot.viewByTitle("Welcome").close(); @@ -122,6 +130,10 @@ projectExplorer = bot.viewByTitle("Project Explorer"); } + public static void deleteProject(String projectName) throws CoreException { + ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).delete(true, null); + } + public static class NodeAvailableAndSelect extends DefaultCondition { private SWTBotTree tree; @@ -303,7 +315,7 @@ .toolbarDropDownButton("Display Selected Console"); org.hamcrest.Matcher withRegex = withRegex(".*" + consoleType + ".*"); - bot.shell("C/C++ - Eclipse Platform").activate(); + focusMainShell(); b.menuItem(withRegex).click(); try { b.pressShortcut(KeyStroke.getInstance("ESC")); @@ -313,6 +325,24 @@ return view; } + /** + * Focus on the main window + */ + public static void focusMainShell() { + SWTBotShell shell = getMainShell(); + shell.activate(); + } + + private static SWTBotShell getMainShell() { + for (SWTBotShell shellBot : bot.shells()) { + if (shellBot.getText().toLowerCase().contains("eclipse")) { + return shellBot; + } + } + fail("Could not find main shell"); + return null; + } + @After public void cleanUp() { exitProjectFolder(); diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AllTests.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AllTests.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AllTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AllTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Red Hat Inc.. + * Copyright (c) 2010, 2014 Red Hat Inc.. * 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 @@ -7,19 +7,43 @@ * * Contributors: * Red Hat Incorporated - initial API and implementation + * Marc Khouzam (Ericsson) - Skip tests if autotools binaries are not available *******************************************************************************/ package org.eclipse.cdt.autotools.ui.tests; +import java.io.IOException; + +import org.eclipse.cdt.utils.spawner.ProcessFactory; +import org.junit.Assume; +import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ - SetConfigurationParameter.class, - TestToolActions.class, - TestEnvironmentVars.class, - TestMakeTargets.class + TestToolActions.class, + TestEnvironmentVars.class, + TestMakeTargets.class, + SetConfigurationParameter.class }) + public class AllTests { - // needed for this class to compile + // needed for this class to compile + @BeforeClass + public static void beforeClassMethod() { + // Verify that the necessary binaries are available, and if they are not, + // the tests will be ignored. + String[] testBinaryCommands = { "libtool --version", + "autoconf --version", + "automake --version" }; + try { + for (String cmd : testBinaryCommands) { + Process process = ProcessFactory.getFactory().exec(cmd); + process.destroy(); + } + } catch (IOException e) { + // If we cannot find any binary, just ignore the tests. + Assume.assumeNoException(e); + } + } } diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java 2015-02-11 19:19:10.000000000 +0000 @@ -34,8 +34,10 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; import org.junit.BeforeClass; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -43,11 +45,11 @@ import org.w3c.dom.NodeList; @RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class SetConfigurationParameter extends AbstractTest { @BeforeClass - public static void beforeClass() throws Exception { - AbstractTest.init("GnuProject0"); + public static void initClass() throws Exception { initConfigParm(); } @@ -96,7 +98,7 @@ // Verify we can set a configuration parameter and that it is recorded in // the .autotools file for the project @Test - public void canSetConfigParm() throws Exception { + public void t1canSetConfigParm() throws Exception { IProject project = checkProject(); assertTrue(project != null); IPath path = project.getLocation(); @@ -137,7 +139,7 @@ // Verify we can build the project with a configuration parameter and that // the configuration parameter can be found in the config.status file. @Test - public void canBuildWithConfigParm() throws Exception { + public void t2canBuildWithConfigParm() throws Exception { projectExplorer.bot().tree().select(projectName); clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project"); @@ -217,7 +219,7 @@ // Verify a new configuration will copy the configuration parameters // of its base configuration. @Test - public void newConfigCopiesParms() throws Exception { + public void t3newConfigCopiesParms() throws Exception { projectExplorer.bot().tree().select(projectName); clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); @@ -249,6 +251,10 @@ assertEquals("--enable-jeff", val); // Verify that the build directory for the new configuration has been // switched to build-debug + shell = bot.shell("Properties for " + projectName); + shell.activate(); + bot.text().setText(""); + bot.tree().select("C/C++ Build"); String buildDir = bot.textWithLabel("Build directory:").getText(); assertTrue(buildDir.endsWith("build-debug")); @@ -368,7 +374,7 @@ // configuration to // another and then cancel without changing configuration settings. @Test - public void doubleRenameCancel() throws Exception { + public void t4doubleRenameCancel() throws Exception { openProperties("Autotools", "Configure Settings"); SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); bot.button("Manage Configurations...").click(); @@ -423,7 +429,7 @@ // configuration to // another and inheriting the settings properly. @Test - public void doubleRenameOk() throws Exception { + public void t5doubleRenameOk() throws Exception { openProperties("Autotools", "Configure Settings"); SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); bot.button("Manage Configurations...").click(); diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java 2015-02-11 19:19:10.000000000 +0000 @@ -24,23 +24,20 @@ import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.junit.BeforeClass; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; @RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestEnvironmentVars extends AbstractTest { - @BeforeClass - public static void beforeClass() throws Exception { - AbstractTest.init("GnuProject2"); - } - // Verify we can pass an unknown env var in configure options and it will be // nulled out // Verifies fix for Bug: #303616 @Test - public void referenceUnknownEnvVar() throws Exception { + public void t1referenceUnknownEnvVar() throws Exception { SWTBotShell shell = openProperties("Autotools", "Configure Settings"); // Set the configure parameters to be --enable-jeff via user-defined // options @@ -80,7 +77,7 @@ // Verify we can set an environment variable and use it as a configure // parameter // Verifies fix for Bug: #303616 - public void setEnvVar() throws Exception { + private void setEnvVar() throws Exception { openProperties("C/C++ Build", "Environment"); bot.button("Add...").click(); SWTBotShell shell = bot.shell("New variable"); @@ -124,7 +121,7 @@ // Verify we can set an environment variable prior to the configuration // command and // it will be seen by the configure script - public void setEnvVarOnCommandLine() throws Exception { + private void setEnvVarOnCommandLine() throws Exception { IPath path = checkProject().getLocation(); // Create a fake configure script which prints out the values of // envvars some_var1, some_var2, and some_var3 @@ -159,7 +156,7 @@ // the script clickContextMenu(projectExplorer.bot().tree().select(projectName), "Reconfigure Project"); - bot.shell("C/C++ - Eclipse Platform").activate(); + focusMainShell(); bot.sleep(3000); SWTBotView consoleView = bot.viewByPartName("Console"); consoleView.setFocus(); diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java 2015-02-11 19:19:10.000000000 +0000 @@ -25,21 +25,18 @@ import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.junit.BeforeClass; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; @RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestMakeTargets extends AbstractTest { - @BeforeClass - public static void beforeClass() throws Exception { - AbstractTest.init("GnuProject3"); - } - @Test // Verify we can build and run the info MakeTarget tool - public void canBuildAndAccessInfoTarget() throws Exception { + public void t1canBuildAndAccessInfoTarget() throws Exception { clickProjectContextMenu("Build Project"); // Wait until the project is built diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java 2015-02-11 19:19:10.000000000 +0000 @@ -20,21 +20,18 @@ import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.junit.BeforeClass; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; @RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestToolActions extends AbstractTest { - @BeforeClass - public static void beforeClass() throws Exception { - AbstractTest.init("GnuProject1"); - } - @Test // Verify we can set the tools via the Autotools Tools page - public void canSeeTools() throws Exception { + public void t1canSeeTools() throws Exception { openProperties("Autotools", "General"); bot.tabItem("Tools Settings").activate(); String aclocalName = bot.textWithLabel("aclocal").getText(); @@ -54,7 +51,7 @@ // Verify we can access the aclocal tool @Test - public void canAccessAclocal() throws Exception { + public void t2canAccessAclocal() throws Exception { IPath path = checkProject().getLocation(); // Verify configure does not exist initially path = path.append("aclocal.m4"); @@ -75,7 +72,7 @@ Pattern p = Pattern.compile(".*Invoking aclocal in.*" + projectName + ".*aclocal --help.*Usage: aclocal.*", Pattern.DOTALL); Matcher m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); // Verify we still don't have an aclocal.m4 file yet f = new File(path.toOSString()); assertTrue(!f.exists()); @@ -92,7 +89,7 @@ p = Pattern.compile(".*Invoking aclocal in.*" + projectName + ".*aclocal.*", Pattern.DOTALL); m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); // We need to wait until the aclocal.m4 file is created so // sleep a bit and look for it...give up after 20 seconds for (int i = 0; i < 40; ++i) { @@ -108,7 +105,7 @@ // Verify we can access the autoconf tool @Test - public void canAccessAutoconf() throws Exception { + public void t3canAccessAutoconf() throws Exception { IPath path = checkProject().getLocation(); // Verify configure does not exist initially path = path.append("configure"); @@ -125,7 +122,7 @@ Pattern p = Pattern.compile(".*Invoking autoconf in.*" + projectName + ".*autoconf.*", Pattern.DOTALL); Matcher m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); // We need to wait until the configure file is created so // sleep a bit and look for it...give up after 20 seconds for (int i = 0; i < 40; ++i) { @@ -152,7 +149,7 @@ p = Pattern.compile(".*Invoking autoconf in.*" + projectName + ".*autoconf.*", Pattern.DOTALL); m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); // We need to wait until the configure file is created so // sleep a bit and look for it...give up after 20 seconds for (int i = 0; i < 40; ++i) { @@ -171,7 +168,7 @@ // Verify we can access the automake tool @Test - public void canAccessAutomake() throws Exception { + public void t4canAccessAutomake() throws Exception { IPath path = checkProject().getLocation(); // Verify configure does not exist initially IPath path2 = path.append("src/Makefile.in"); @@ -197,7 +194,7 @@ Pattern p = Pattern.compile(".*Invoking automake in.*" + projectName + ".*automake --help.*Usage:.*", Pattern.DOTALL); Matcher m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); // Verify we still don't have Makefile.in files yet f = new File(path.toOSString()); assertTrue(!f.exists()); @@ -221,7 +218,7 @@ + ".*automake --add-missing Makefile src/Makefile.*", Pattern.DOTALL); m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); // We need to wait until the Makefile.in files are created so // sleep a bit and look for it...give up after 20 seconds for (int i = 0; i < 40; ++i) { @@ -242,7 +239,7 @@ // Verify we can access the libtoolize tool @Test - public void canAccessLibtoolize() throws Exception { + public void t5canAccessLibtoolize() throws Exception { clickProjectContextMenu("Invoke Autotools", "Invoke Libtoolize"); SWTBotShell shell = bot.shell("Libtoolize Options"); shell.activate(); @@ -256,18 +253,18 @@ Pattern p = Pattern.compile(".*Invoking libtoolize in.*" + projectName + ".*libtoolize --help.*Usage: libtoolize.*", Pattern.DOTALL); Matcher m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); } // Verify we can access the libtoolize tool @Test - public void canAccessAutoheader() throws Exception { + public void t6canAccessAutoheader() throws Exception { clickProjectContextMenu("Invoke Autotools", "Invoke Autoheader"); SWTBotShell shell = bot.shell("Autoheader Options"); shell.activate(); bot.text(0).typeText("--help"); bot.button("OK").click(); - bot.sleep(1000); + bot.sleep(2000); SWTBotView consoleView = bot.viewByPartName("Console"); consoleView.setFocus(); String output = consoleView.bot().styledText().getText(); @@ -275,12 +272,12 @@ Pattern p = Pattern.compile(".*Invoking autoheader in.*" + projectName + ".*autoheader --help.*Usage:.*autoheader.*", Pattern.DOTALL); Matcher m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); } // Verify we can access the autoreconf tool @Test - public void canAccessAutoreconf() throws Exception { + public void t7canAccessAutoreconf() throws Exception { IPath path = checkProject().getLocation(); // Remove a number of generated files File f = new File(path.append("src/Makefile.in").toOSString()); @@ -316,7 +313,7 @@ Pattern p = Pattern.compile(".*Invoking autoreconf in.*" + projectName + ".*autoreconf --help.*Usage: .*autoreconf.*", Pattern.DOTALL); Matcher m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); clickProjectContextMenu("Invoke Autotools", "Invoke Autoreconf"); shell = bot.shell("Autoreconf Options"); shell.activate(); @@ -324,24 +321,22 @@ bot.button("OK").click(); // We need to wait until the Makefile.in file is created so // sleep a bit and look for it - bot.sleep(3000); + bot.sleep(5000); + // Verify a number of generated files now exist - f = new File(path.append("Makefile.in").toOSString()); - assertTrue(f.exists()); - f = new File(path.append("src/Makefile.in").toOSString()); - assertTrue(f.exists()); - f = new File(path.append("Makefile.in").toOSString()); - assertTrue(f.exists()); - f = new File(path.append("configure").toOSString()); - assertTrue(f.exists()); - f = new File(path.append("config.status").toOSString()); - assertTrue(!f.exists()); // shouldn't have run configure - f = new File(path.append("config.sub").toOSString()); - assertTrue(f.exists()); + String[] fileList = { "Makefile.in", "src/Makefile.in", "configure", "config.sub" }; + for (String name : fileList) { + f = new File(path.append(name).toOSString()); + assertTrue("Missing: " + name, f.exists()); + } + + String name = "config.status"; + f = new File(path.append(name).toOSString()); + assertTrue("Mistakenly found: " + name, !f.exists()); // shouldn't have run configure } @Test - public void canReconfigureProject() throws Exception { + public void t8canReconfigureProject() throws Exception { IPath path = checkProject().getLocation(); // Remove a number of generated files File f = new File(path.append("src/Makefile.in").toOSString()); @@ -391,7 +386,7 @@ // Verify we can set and reset the tools via the Autotools Tools page // Verifies bug #317345 @Test - public void canResetTools() throws Exception { + public void t9canResetTools() throws Exception { openProperties("Autotools", "General"); bot.tabItem("Tools Settings").activate(); bot.textWithLabel("aclocal").setText(""); @@ -437,7 +432,7 @@ // Verify we can set the tools via the Autotools Tools page @Test - public void canSetTools() throws Exception { + public void u1canSetTools() throws Exception { openProperties("Autotools", "General"); bot.tabItem("Tools Settings").activate(); bot.textWithLabel("aclocal").setText(""); @@ -467,7 +462,7 @@ Pattern p = Pattern.compile(".*Invoking aclocal in.*" + projectName + ".*automake --help.*Usage:.*automake.*", Pattern.DOTALL); Matcher m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); clickProjectContextMenu("Invoke Autotools", "Invoke Automake"); shell = bot.shell("Automake Options"); @@ -482,7 +477,7 @@ p = Pattern.compile(".*Invoking automake in.*" + projectName + ".*autoconf --help.*Usage:.*autoconf.*", Pattern.DOTALL); m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); clickProjectContextMenu("Invoke Autotools", "Invoke Autoheader"); shell = bot.shell("Autoheader Options"); @@ -497,7 +492,7 @@ p = Pattern.compile(".*Invoking autoheader in.*" + projectName + ".*autoreconf --help.*Usage:.*autoreconf.*", Pattern.DOTALL); m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); clickProjectContextMenu("Invoke Autotools", "Invoke Autoreconf"); shell = bot.shell("Autoreconf Options"); @@ -512,7 +507,7 @@ p = Pattern.compile(".*Invoking autoreconf in.*" + projectName + ".*libtoolize --help.*Usage:.*libtoolize.*", Pattern.DOTALL); m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); clickProjectContextMenu("Invoke Autotools", "Invoke Libtoolize"); shell = bot.shell("Libtoolize Options"); @@ -527,7 +522,7 @@ p = Pattern.compile(".*Invoking libtoolize in.*" + projectName + ".*aclocal --help.*Usage:.*aclocal.*", Pattern.DOTALL); m = p.matcher(output); - assertTrue(m.matches()); + assertTrue("Got: " + output, m.matches()); } } diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.gnu.build-feature/feature.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.gnu.build-feature/feature.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.gnu.build-feature/feature.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.gnu.build-feature/feature.xml 2015-02-11 19:19:10.000000000 +0000 @@ -2,7 +2,7 @@ diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.gnu.build-feature/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.gnu.build-feature/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.gnu.build-feature/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.gnu.build-feature/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.gnu.build.source-feature/feature.xml 2015-02-11 19:19:10.000000000 +0000 @@ -2,7 +2,7 @@ diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.gnu.build.source-feature/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.gnu.build.source-feature/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.gnu.build.source-feature/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.gnu.build.source-feature/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.core/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.core/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.core/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.core/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.core.tests/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.core.tests/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.core.tests/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.core.tests/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml @@ -23,7 +23,7 @@ ${tycho-version} false - -Xms256m -Xmx512m -XX:MaxPermSize=256M + ${tycho.testArgLine} -Xms256m -Xmx512m -XX:MaxPermSize=256M **/AutomatedIntegrationSuite.* diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.ui/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.ui/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.ui/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.ui/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/WordPartDetector.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/WordPartDetector.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/WordPartDetector.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/WordPartDetector.java 2015-02-11 19:19:10.000000000 +0000 @@ -119,7 +119,11 @@ // the cursor is on the first word which is "include" keyword // so find the second word which is the first include file String sub = line.substring(line.indexOf(' ', position)).trim(); - wordPart = sub.substring(0, sub.indexOf(' ')).trim(); + if (sub.contains(" ")) { //$NON-NLS-1$ + wordPart = sub.substring(0, sub.indexOf(' ')).trim(); + } else { + wordPart = sub; + } } else { wordPart = findWord(line, position); } diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.ui.tests/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.ui.tests/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.make.ui.tests/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.make.ui.tests/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml @@ -23,7 +23,7 @@ ${tycho-version} true - ${base.ui.test.vmargs} -ea -Xms256m -Xmx512m -XX:MaxPermSize=256M + ${tycho.testArgLine} ${base.ui.test.vmargs} -ea -Xms256m -Xmx512m -XX:MaxPermSize=256M **/AllMakeUITests.* diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2011 Intel Corporation and others. + * Copyright (c) 2006, 2015 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 @@ -68,6 +68,7 @@ import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo; import org.eclipse.cdt.managedbuilder.pdomdepgen.PDOMDependencyGenerator; import org.eclipse.cdt.utils.EFSExtensionManager; +import org.eclipse.cdt.utils.UNCPathConverter; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; @@ -987,7 +988,8 @@ } private IPath getProjectLocation() { - return new Path(fProject.getLocationURI().getPath()); + URI uri = fProject.getLocationURI(); + return UNCPathConverter.toPath(uri); } private BuildResource[] addOutputs(IPath paths[], BuildIOType buildArg, IPath outDirPath){ @@ -997,7 +999,7 @@ IPath outFullPath = path; IPath outWorkspacePath = path; IPath outProjPath; - IPath projLocation = new Path(fProject.getLocationURI().getPath()); + IPath projLocation = getProjectLocation(); if(outFullPath.isAbsolute()){ outProjPath = outFullPath; diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java 2015-02-11 19:19:10.000000000 +0000 @@ -342,7 +342,8 @@ || fKind.intValue() == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY || isLibrariesInput()) { IToolChain toolChain = getToolChain(); - if (!toolChain.isExtensionElement()) { + /* toolChain can be null e.g. in tools for custom build steps */ + if (toolChain != null && !toolChain.isExtensionElement()) { long artifactTimeStamp = getArtifactTimeStamp(toolChain); if (0 != artifactTimeStamp) { String[] paths = getPaths(); diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core.tests/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core.tests/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core.tests/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core.tests/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml @@ -33,7 +33,7 @@ true - ${base.ui.test.vmargs} -Xms256m -Xmx512m -XX:MaxPermSize=256M + ${tycho.testArgLine} ${base.ui.test.vmargs} -Xms256m -Xmx512m -XX:MaxPermSize=256M **/AllManagedBuildTests.* diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -2368,6 +2368,30 @@ } } + public void testDesRebuildStateWithCustomBuildStep() { + /* This test captures Bug 389536 */ + IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe"); + try { + CCProjectNature.addCCNature(project, null); + } catch (CoreException e1) { + fail("fail to add CC nature"); + } + + IFile testYFile = ManagedBuildTestHelper.createFile(project, "test.y"); + + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + IManagedProject mProj = info.getManagedProject(); + IConfiguration cfg = mProj.getConfigurations()[0]; + + IResourceConfiguration testYCfg = cfg.createResourceConfiguration(testYFile); + ITool bisonTool = testYCfg.createTool(null, "tool.bison", "Bison", false); + bisonTool.setCustomBuildStep(true); + IInputType bisonInputType = bisonTool.createInputType(null, "inputtype.bison", "Bison Inputfiles", false); + bisonInputType.createAdditionalInput(""); + cfg.setRebuildState(false); + assertFalse(cfg.needsRebuild()); + } + private void doTestTool(ITool tool){ IBuildObject obj = tool.getParent(); IConfiguration cfg; diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.gnu.ui/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.gnu.ui/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.gnu.ui/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.gnu.ui/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.ui/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.ui/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.ui/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.ui/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties 2015-02-11 19:19:10.000000000 +0000 @@ -8,6 +8,7 @@ # Contributors: # IBM - Initial API and implementation # Andrew Gvozdev (Quoin Inc.) - Combined managedbuilder.ui bundles to NLS message format, bug 318812 +# Roberto Oliveira - Removed an unused message ############################################################################### BuilderSettingsTab_0=Builder @@ -281,7 +282,6 @@ CConfigWizardPage_13=Advanced settings... CMainWizardPage_0=Project type: CDTConfigWizardPage_0=Select configurations -ConvertTargetAction_No_Converter=No converter NewCfgDialog_2=Cannot create new configuration NewCfgDialog_3=-- not selected -- diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.ui.tests/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.ui.tests/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.cdt.managedbuilder.ui.tests/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.cdt.managedbuilder.ui.tests/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml @@ -23,7 +23,7 @@ ${tycho-version} true - ${base.ui.test.vmargs} -Xms256m -Xmx512m -XX:MaxPermSize=256M + ${tycho.testArgLine} ${base.ui.test.vmargs} -Xms256m -Xmx512m -XX:MaxPermSize=256M **/AllManagedBuildUITests.* diff -Nru eclipse-cdt-8.5.0/build/org.eclipse.linuxtools.cdt.autotools.core/pom.xml eclipse-cdt-8.6.0/build/org.eclipse.linuxtools.cdt.autotools.core/pom.xml --- eclipse-cdt-8.5.0/build/org.eclipse.linuxtools.cdt.autotools.core/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/build/org.eclipse.linuxtools.cdt.autotools.core/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.checkers/pom.xml eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.checkers/pom.xml --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.checkers/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.checkers/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.checkers.ui/pom.xml eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.checkers.ui/pom.xml --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.checkers.ui/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.checkers.ui/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/pom.xml eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/pom.xml --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java 2015-02-11 19:19:10.000000000 +0000 @@ -95,6 +95,8 @@ * @noreference This method is not intended to be referenced by clients. */ public static void log(Throwable e) { + if (Boolean.valueOf(System.getProperty("codan.rethrow"))) //$NON-NLS-1$ + throw new RuntimeException(e); log("Internal Error", e); //$NON-NLS-1$ } diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java 2015-02-11 19:19:10.000000000 +0000 @@ -15,7 +15,7 @@ /** * Abstract node with one incoming arc (node) - * + * */ public abstract class AbstractSingleIncomingNode extends AbstractBasicBlock implements ISingleIncoming { private IBasicBlock prev; @@ -34,7 +34,7 @@ @Override public int getIncomingSize() { - return 1; + return prev!=null?1:0; } @Override @@ -44,7 +44,7 @@ /** * Sets the incoming node - * + * * @param prev */ public void setIncoming(IBasicBlock prev) { diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java 2015-02-11 19:19:10.000000000 +0000 @@ -142,10 +142,14 @@ if (result.contains(start)) return; result.add(start); - IBasicBlock[] outgoingNodes = start.getOutgoingNodes(); - for (int i = 0; i < outgoingNodes.length; i++) { - IBasicBlock b = outgoingNodes[i]; - getNodes(b, result); + for (IBasicBlock bb : start.getOutgoingNodes()) { + getNodes(bb, result); + } + if (start instanceof IConnectorNode) { + // special case where connect can have some incoming branch nodes not in the graph + for (IBasicBlock bb : start.getIncomingNodes()) { + getNodes(bb, result); + } } } } diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanRunner.java eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanRunner.java --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanRunner.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanRunner.java 2015-02-11 19:19:10.000000000 +0000 @@ -76,31 +76,29 @@ ICheckerInvocationContext context = new CheckerInvocationContext(resource); try { for (IChecker checker : chegistry) { - try { - if (monitor.isCanceled()) - return; - if (chegistry.isCheckerEnabled(checker, resource, checkerLaunchMode)) { - synchronized (checker) { - try { - checker.before(resource); - CheckersTimeStats.getInstance().checkerStart(checker.getClass().getName()); - if (checkerLaunchMode == CheckerLaunchMode.RUN_AS_YOU_TYPE) { - ((IRunnableInEditorChecker) checker).processModel(model, context); - } else { - checker.processResource(resource, context); - } - } finally { - CheckersTimeStats.getInstance().checkerStop(checker.getClass().getName()); - checker.after(resource); + if (monitor.isCanceled()) + return; + if (chegistry.isCheckerEnabled(checker, resource, checkerLaunchMode)) { + synchronized (checker) { + try { + checker.before(resource); + CheckersTimeStats.getInstance().checkerStart(checker.getClass().getName()); + if (checkerLaunchMode == CheckerLaunchMode.RUN_AS_YOU_TYPE) { + ((IRunnableInEditorChecker) checker).processModel(model, context); + } else { + checker.processResource(resource, context); } + } catch (OperationCanceledException e) { + return; + } catch (Throwable e) { + CodanCorePlugin.log(e); + } finally { + CheckersTimeStats.getInstance().checkerStop(checker.getClass().getName()); + checker.after(resource); } } - monitor.worked(1); - } catch (OperationCanceledException e) { - return; - } catch (Throwable e) { - CodanCorePlugin.log(e); } + monitor.worked(1); } } finally { context.dispose(); diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core.cxx/pom.xml eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core.cxx/pom.xml --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core.cxx/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core.cxx/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java 2015-02-11 19:19:10.000000000 +0000 @@ -13,7 +13,9 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; import org.eclipse.cdt.codan.core.cxx.Activator; import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock; @@ -27,6 +29,7 @@ import org.eclipse.cdt.codan.core.model.cfg.ISingleOutgoing; import org.eclipse.cdt.codan.core.model.cfg.IStartNode; import org.eclipse.cdt.codan.internal.core.cfg.AbstractBasicBlock; +import org.eclipse.cdt.codan.internal.core.cfg.ConnectorNode; import org.eclipse.cdt.codan.internal.core.cfg.DecisionNode; import org.eclipse.cdt.codan.internal.core.cfg.JumpNode; import org.eclipse.cdt.core.dom.ast.IASTBreakStatement; @@ -71,7 +74,7 @@ CxxNodeFactory factory = new CxxNodeFactory(); IConnectorNode outerBreak; IConnectorNode outerContinue; - HashMap labels = new HashMap<>(); + Map labels = new LinkedHashMap<>(); /** * Builds the graph. @@ -80,9 +83,18 @@ IASTStatement body = def.getBody(); start = new CxxStartNode(); exits = new ArrayList<>(); - dead = new ArrayList<>(); + dead = new LinkedHashSet<>(); IBasicBlock last = createSubGraph(start, body); - if (!(last instanceof IExitNode) && !deadConnector(last)) { + for (IBranchNode label : labels.values()) { + IConnectorNode conn = (IConnectorNode) label.getOutgoing(); + if (conn.getIncomingSize() <= 1 && label.getIncoming() == null) + dead.add(label); + else { + dead.remove(label); + dead.remove(conn); + } + } + if (!(last instanceof IExitNode || last instanceof IJumpNode || deadConnector(last))) { returnExit = factory.createExitNode(null); returnExit.setStartNode(start); addOutgoing(last, returnExit); @@ -177,15 +189,12 @@ } else if (body instanceof IASTLabelStatement) { IASTLabelStatement ast = (IASTLabelStatement) body; String labelName = ast.getName().toString(); - IBranchNode labNode = (IBranchNode) labels.get(labelName); + IBranchNode labNode = labels.get(labelName); IConnectorNode conn; if (labNode != null) { conn = (IConnectorNode) labNode.getOutgoing(); addOutgoing(prev, labNode); } else { - // labeled statement contains of connector for jumps, branch for - // label - // and nested statement conn = createLabelNodes(prev, labelName); } return createSubGraph(conn, ast.getNestedStatement()); @@ -193,14 +202,16 @@ IASTGotoStatement ast = (IASTGotoStatement) body; String labelName = ast.getName().toString(); IConnectorNode conn; - IBranchNode labNode = (IBranchNode) labels.get(labelName); + IBranchNode labNode = labels.get(labelName); if (labNode != null) { conn = (IConnectorNode) labNode.getOutgoing(); } else { conn = createLabelNodes(null, labelName); } IJumpNode gotoNode = factory.createJumpNode(); - ((JumpNode) gotoNode).setJump(conn, labNode != null); + boolean backward = labNode != null; // This is not accurate XXX + ((JumpNode) gotoNode).setJump(conn, backward); + ((ConnectorNode) conn).addIncoming(gotoNode); addOutgoing(prev, gotoNode); return gotoNode; } else if (body instanceof IASTProblemStatement) { @@ -271,9 +282,19 @@ return node; } + /** + * labeled statement consists of connector for jumps, + * branch for label and statement + * + * @param prev + * @param labelName + * @return + */ protected IConnectorNode createLabelNodes(IBasicBlock prev, String labelName) { IBranchNode branch = factory.createBranchNode(labelName); - if (prev != null) + if (prev == null || prev instanceof IJumpNode || prev instanceof IExitNode) + ;// don't do anything, leave dangling branch node + else addOutgoing(prev, branch); labels.put(labelName, branch); IConnectorNode conn = factory.createConnectorNode(); @@ -383,8 +404,42 @@ } private IBasicBlock createRangeBasedFor(IBasicBlock prev, ICPPASTRangeBasedForStatement forNode) { - // TODO(Alena Laskavaia): Implement proper graph. - return createSubGraph(prev, forNode.getBody()); + // Add initializer + IPlainNode init = factory.createPlainNode(forNode.getDeclaration()); + addOutgoing(prev, init); + prev = init; + // Add continue connector + IConnectorNode beforeCheck = factory.createConnectorNode(); + addOutgoing(prev, beforeCheck); + // Decision node + CxxDecisionNode decision = factory.createDecisionNode(forNode.getInitializerClause()); // XXX test expression + addOutgoing(beforeCheck, decision); + // Add break connector + IConnectorNode nBreak = factory.createConnectorNode(); + decision.setMergeNode(nBreak); + // Create body and jump to continue node + IBranchNode loopStart = factory.createBranchNode(IBranchNode.THEN); + addOutgoing(decision, loopStart); + // Set break/continue + IConnectorNode nContinue = factory.createConnectorNode(); + IConnectorNode savedContinue = outerContinue; + IConnectorNode savedBreak = outerBreak; + outerContinue = nContinue; + outerBreak = nBreak; + IBasicBlock endBody = createSubGraph(loopStart, forNode.getBody()); + outerContinue = savedContinue; + outerBreak = savedBreak; + // inc + IPlainNode inc = factory.createPlainNode(); // XXX increment + addOutgoing(endBody, nContinue); + addOutgoing(nContinue, inc); + // Connect with backward link + addJump(inc, beforeCheck, true); + // Add "else" branch + IBranchNode loopEnd = factory.createBranchNode(IBranchNode.ELSE); + addOutgoing(decision, loopEnd); + addJump(loopEnd, nBreak); + return nBreak; } protected IBasicBlock createWhile(IBasicBlock prev, IASTWhileStatement body) { @@ -464,15 +519,15 @@ return (IJumpNode) prev; if (prev instanceof IExitNode) return null; - IJumpNode jump = factory.createJumpNode(); + JumpNode jump = (JumpNode) factory.createJumpNode(); addOutgoing(prev, jump); - addOutgoing(jump, conn); - ((JumpNode) jump).setBackward(backward); + jump.setJump(conn, backward); + ((ConnectorNode) conn).addIncoming(jump); return jump; } private void addOutgoing(IBasicBlock prev, IBasicBlock node) { - if (prev instanceof IExitNode || prev == null) { + if (prev instanceof IExitNode || prev instanceof IJumpNode || prev == null) { dead.add(node); return; } @@ -500,7 +555,7 @@ if (node instanceof ICfgData) { IASTNode ast = (IASTNode) ((ICfgData) node).getData(); if (ast instanceof IASTExpression) { - IValue dvalue = Value.create((IASTExpression) ast, 5); + IValue dvalue = Value.create((IASTExpression) ast); Long numericalValue = dvalue.numericalValue(); if (numericalValue == null) return false; diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core.test/pom.xml eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core.test/pom.xml --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core.test/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core.test/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml @@ -24,7 +24,7 @@ true - ${base.ui.test.vmargs} -ea -Xms256m -Xmx512m -XX:MaxPermSize=256M + ${tycho.testArgLine} ${base.ui.test.vmargs} -ea -Xms256m -Xmx512m -XX:MaxPermSize=256M **/AutomatedIntegrationSuite.* diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cfg/ControlFlowGraphTest.java eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cfg/ControlFlowGraphTest.java --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cfg/ControlFlowGraphTest.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cfg/ControlFlowGraphTest.java 2015-02-11 19:19:10.000000000 +0000 @@ -65,7 +65,7 @@ } /** - * + * */ private void checkCfg(boolean decision) { assertNotNull(graph); @@ -85,6 +85,8 @@ nodes: for (int i = 0; i < incomingNodes.length; i++) { IBasicBlock b = incomingNodes[i]; if (b == null) { + if (node instanceof IBranchNode) + continue nodes; // check if dead node Iterator iterator = graph.getUnconnectedNodeIterator(); boolean dead = false; @@ -153,6 +155,14 @@ processAst(tu); } + private void buildCfg_C(String code) { + parse(code, ParserLanguage.C, true); + processAst(tu); + } + private void buildCfg_CPP(String code) { + parse(code, ParserLanguage.CPP, true); + processAst(tu); + } /** * @param des * @return @@ -163,7 +173,7 @@ /** * Return first node after the branch - * + * * @param des * @return */ @@ -180,7 +190,7 @@ /** * Return node where control jumps, following the chain until jump is hit - * + * * @param a * @return */ @@ -199,7 +209,7 @@ // main() { // int a; - // a=1; + // a=1; // } public void test_basic() { buildAndCheck(getAboveComment()); @@ -342,7 +352,7 @@ /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.codan.core.test.CodanFastCxxAstTestCase#getChecker() */ @Override @@ -436,7 +446,7 @@ // } // } public void test_infiniloop() { - buildCfg(getAboveComment(), false); + buildCfg_C(getAboveComment()); checkCfg(false); IStartNode startNode = graph.getStartNode(); IConnectorNode conn = (IConnectorNode) startNode.getOutgoing(); @@ -450,4 +460,94 @@ assertNotNull(m2); assertNull(m1); } + + // void foo() { + // for (int i=0;i org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java 2015-02-11 19:19:10.000000000 +0000 @@ -38,35 +38,36 @@ @Override public void run(IAction action) { - Job job = new Job(CodanUIMessages.Job_TitleRunningAnalysis) { - @SuppressWarnings("unchecked") - @Override - protected IStatus run(final IProgressMonitor monitor) { - IStructuredSelection ss = (IStructuredSelection) sel; - int count = ss.size(); - monitor.beginTask(getName(), count * 100); - if (monitor.isCanceled()) - return Status.CANCEL_STATUS; - for (Iterator iterator = ss.iterator(); iterator.hasNext();) { - Object o = iterator.next(); - if (o instanceof IAdaptable) { - o = ((IAdaptable) o).getAdapter(IResource.class); - } - if (o instanceof IResource) { - IResource res = (IResource) o; - SubProgressMonitor subMon = new SubProgressMonitor(monitor, 100); - CodanRuntime.getInstance().getBuilder().processResource(res, subMon, CheckerLaunchMode.RUN_ON_DEMAND); - if (subMon.isCanceled()) - return Status.CANCEL_STATUS; - } + if (sel instanceof IStructuredSelection) { + final IStructuredSelection ss = (IStructuredSelection) sel; + Job job = new Job(CodanUIMessages.Job_TitleRunningAnalysis) { + @Override + protected IStatus run(final IProgressMonitor monitor) { + int count = ss.size(); + monitor.beginTask(getName(), count * 100); if (monitor.isCanceled()) return Status.CANCEL_STATUS; + for (Iterator iterator = ss.iterator(); iterator.hasNext();) { + Object o = iterator.next(); + if (o instanceof IAdaptable) { + o = ((IAdaptable) o).getAdapter(IResource.class); + } + if (o instanceof IResource) { + IResource res = (IResource) o; + SubProgressMonitor subMon = new SubProgressMonitor(monitor, 100); + CodanRuntime.getInstance().getBuilder().processResource(res, subMon, CheckerLaunchMode.RUN_ON_DEMAND); + if (subMon.isCanceled()) + return Status.CANCEL_STATUS; + } + if (monitor.isCanceled()) + return Status.CANCEL_STATUS; + } + return Status.OK_STATUS; } - return Status.OK_STATUS; - } - }; - job.setUser(true); - job.schedule(); + }; + job.setUser(true); + job.schedule(); + } } @Override diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/views/ControlFlowGraphView.java eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/views/ControlFlowGraphView.java --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/views/ControlFlowGraphView.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/views/ControlFlowGraphView.java 2015-02-11 19:19:10.000000000 +0000 @@ -86,6 +86,7 @@ * are presented in the same way everywhere. *

*/ +@SuppressWarnings("restriction") public class ControlFlowGraphView extends ViewPart { /** * The ID of the view as specified by the extension. @@ -123,20 +124,26 @@ if (parent instanceof Collection) { return ((Collection) parent).toArray(); } else if (parent instanceof IControlFlowGraph) { - Collection blocks = getFlat(((IControlFlowGraph) parent).getStartNode(), new ArrayList()); + IControlFlowGraph cfg = (IControlFlowGraph) parent; + Collection blocks = getFlat(cfg.getStartNode(), new ArrayList()); DeadNodes dead = new DeadNodes(); - Iterator iter = ((IControlFlowGraph) parent).getUnconnectedNodeIterator(); + Iterator iter = cfg.getUnconnectedNodeIterator(); for (; iter.hasNext();) { IBasicBlock iBasicBlock = iter.next(); dead.add(iBasicBlock); } - ArrayList all = new ArrayList(); + ArrayList all = new ArrayList(); all.addAll(blocks); + // labeled statements disjoined from the rest + for (IBasicBlock node : cfg.getNodes()) { + if (node instanceof IBranchNode && node.getIncomingSize() == 0 && !dead.contains(node)) + all.add(node); + } if (dead.size() > 0) all.add(dead); return all.toArray(); } else if (parent instanceof IDecisionNode) { - ArrayList blocks = new ArrayList(); + ArrayList blocks = new ArrayList(); IBasicBlock[] outgoingNodes = ((IDecisionNode) parent).getOutgoingNodes(); for (int i = 0; i < outgoingNodes.length; i++) { IBasicBlock arc = outgoingNodes[i]; diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.ui.cxx/plugin.xml eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.ui.cxx/plugin.xml --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.ui.cxx/plugin.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.ui.cxx/plugin.xml 2015-02-11 19:19:10.000000000 +0000 @@ -21,7 +21,10 @@ - + diff -Nru eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml --- eclipse-cdt-8.5.0/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/codan/org.eclipse.cdt.codan.ui.cxx/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.alltests/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.alltests/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.alltests/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.alltests/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml @@ -23,7 +23,7 @@ ${tycho-version} false - -Xms256m -Xmx512m -XX:MaxPermSize=256M + ${tycho.testArgLine} -Xms256m -Xmx512m -XX:MaxPermSize=256M **/UPCParserTestSuite.* diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF 2015-02-11 19:19:10.000000000 +0000 @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true -Bundle-Version: 5.8.0.qualifier +Bundle-Version: 5.9.1.qualifier Bundle-Activator: org.eclipse.cdt.core.CCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java 2015-02-11 19:19:10.000000000 +0000 @@ -167,7 +167,7 @@ } /** - * Return true if IFile is a shared library, i.e. libxx.so + * Returns true if IFile is a shared library, i.e. libxx.so */ public boolean isSharedLib(IFile file) { ICElement celement = create(file); @@ -178,7 +178,7 @@ } /** - * Return true if IFile is a an object(ELF), i.e. *.o + * Returns true if IFile is a an object(ELF), i.e. *.o */ public boolean isObject(IFile file) { ICElement celement = create(file); @@ -189,7 +189,7 @@ } /** - * Return true if IFile is an ELF executable + * Returns true if IFile is an ELF executable */ public boolean isExecutable(IFile file) { ICElement celement = create(file); @@ -200,7 +200,7 @@ } /** - * Return true if IFile is an ELF. + * Returns true if IFile is an ELF. */ public boolean isBinary(IFile file) { ICElement celement = create(file); @@ -208,7 +208,7 @@ } /** - * Return true if IFile is an Achive, *.a + * Returns true if IFile is an Achive, *.a */ public boolean isArchive(IFile file) { ICElement celement = create(file); @@ -216,7 +216,7 @@ } /** - * Return true if IFile is a possible TranslationUnit. + * Returns true if IFile is a possible TranslationUnit. */ public static boolean isTranslationUnit(IFile file) { if (file != null) { @@ -229,7 +229,7 @@ } /** - * Return an array of the register contentTypes. + * Returns an array of the register contentTypes. * @return String[] ids */ public static String[] getRegistedContentTypeIds() { @@ -237,7 +237,7 @@ } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidTranslationUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -254,7 +254,7 @@ } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidHeaderUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -269,7 +269,7 @@ } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidSourceUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -289,7 +289,7 @@ } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidCSourceUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -303,7 +303,7 @@ } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidCXXSourceUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -317,7 +317,7 @@ } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidASMSourceUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -331,7 +331,7 @@ } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidCXXHeaderUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -345,7 +345,7 @@ } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidCHeaderUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -379,7 +379,7 @@ } /** - * Return true if project has C nature. + * Returns true if project has C nature. */ public static boolean hasCNature(IProject project) { try { @@ -390,7 +390,7 @@ } /** - * Return true if project has C++ nature. + * Returns true if project has C++ nature. */ public static boolean hasCCNature(IProject project) { try { @@ -1036,7 +1036,7 @@ } /** - * Return the IPathEntryStore of the project. + * Returns the IPathEntryStore of the project. * @throws CoreException */ public static IPathEntryStore getPathEntryStore(IProject project) throws CoreException { @@ -1113,7 +1113,7 @@ } /** - * Return the singleton. + * Returns the singleton. */ public static CoreModel getDefault() { if (cmodel == null) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICContainer.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICContainer.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICContainer.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICContainer.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 QNX Software Systems and others. + * Copyright (c) 2000, 2015 QNX Software Systems 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 @@ -7,11 +7,14 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.model; +import org.eclipse.core.resources.IContainer; + /** - * A C Folder Resource. + * A C folder resource. * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. @@ -22,12 +25,12 @@ * It does not transitively answer non-C resources contained in folders; * these would have to be explicitly iterated over. *

- * Non-C resources includes files, folders, projects not accounted for. + * Non-C resources includes files, folders, projects not accounted for. *

* * @return an array of non-C resources directly contained in this project * @exception CModelException if this element does not exist or if an - * exception occurs while accessing its corresponding resource + * exception occurs while accessing its corresponding resource */ Object[] getNonCResources() throws CModelException; @@ -41,11 +44,9 @@ ITranslationUnit[] getTranslationUnits() throws CModelException; /** - * Returns the translation unit with the specified name - * in this container (for example, "foobar.c"). - * The name has to be a valid translation unit name. - * This is a handle-only operation. The celement - * may or may not exist. + * Returns the translation unit with the specified name in this container + * (for example, {@code "foobar.c"}). The name has to be a valid translation unit name. + * This is a handle-only operation. The celement may or may not exist. * * @param name the given name * @return the translation unit with the specified name in this container @@ -54,46 +55,43 @@ /** * Returns the all the binaries of this container. - * - * @throws CModelException */ IBinary[] getBinaries() throws CModelException; /** - * Return the binary for this name, it must be a - * valid binary + * Returns the binary for this name, it must be a valid binary. * This is a handle-only operation. The container may or may not exist. */ IBinary getBinary(String name); /** - * Returns all the archive of this container - * - * @throws CModelException + * Returns all the archives of this container. */ IArchive[] getArchives() throws CModelException; /** - * This is a handle-only operation. The container - * may or may not exist. + * This is a handle-only operation. The container may or may not exist. */ IArchive getArchive(String name); /** - * Return al the child containers of this container. - * - * @throws CModelException + * Returns all the child containers of this container. */ ICContainer[] getCContainers() throws CModelException; /** - * Returns the container with the given name. - * An empty string indicates the default package. - * This is a handle-only operation. The celement - * may or may not exist. + * Returns the container with the given name. An empty string indicates the default package. + * This is a handle-only operation. The celement may or may not exist. * - * @param name the given container + * @param name the name of a nested container * @return the container with the given name */ ICContainer getCContainer(String name); + + /** + * Returns the corresponding IContainer. + * @since 5.9 + */ + @Override + IContainer getResource(); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModel.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModel.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModel.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModel.java 2015-02-11 19:19:10.000000000 +0000 @@ -19,11 +19,10 @@ * the C model element. * The C model element needs to be opened before it can be navigated or manipulated. * The C model element has no parent (it is the root of the C element - * hierarchy). Its children are ICProjects. + * hierarchy). Its children are {@code ICProject}s. *

* This interface provides methods for performing copy, move, rename, and * delete operations on multiple C elements. - *

* * @see CoreModel#create(org.eclipse.core.resources.IWorkspaceRoot) * @@ -39,56 +38,55 @@ * its associated container. *

* Optionally, each copy can positioned before a sibling - * element. If null is specified for a given sibling, the copy + * element. If {@code null} is specified for a given sibling, the copy * is inserted as the last child of its associated container. - *

*

* Optionally, each copy can be renamed. If - * null is specified for the new name, the copy + * {@code null} is specified for the new name, the copy * is not renamed. - *

*

* Optionally, any existing child in the destination container with - * the same name can be replaced by specifying true for + * the same name can be replaced by specifying {@code true} for * force. Otherwise an exception is thrown in the event that a name * collision occurs. - *

* * @param elements the elements to copy * @param containers the container, or list of containers - * @param siblings the list of siblings element any of which may be - * null; or null - * @param renamings the list of new names any of which may be - * null; or null - * @param replace true if any existing child in a target container - * with the target name should be replaced, and false to throw an - * exception in the event of a name collision + * @param siblings the list of sibling elements, any of which may be + * {@code null}, or {@code null} + * @param renamings the list of new names, any of which may be + * {@code null}, or {@code null} + * @param replace {@code true} if any existing child in a target container + * with the target name should be replaced, and {@code false} to throw an + * exception in the event of a name collision * @param monitor a progress monitor * @exception CModelException if an element could not be copied. Reasons include: *
    *
  • A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)
  • - *
  • A CoreException occurred while updating an underlying resource - *
  • A container is of an incompatible type (INVALID_DESTINATION) - *
  • A sibling is not a child of it associated container (INVALID_SIBLING) - *
  • A new name is invalid (INVALID_NAME) + *
  • A {@code CoreException} occurred while updating an underlying resource + *
  • A container is of an incompatible type ({@code INVALID_DESTINATION}) + *
  • A sibling is not a child of it associated container ({@code INVALID_SIBLING}) + *
  • A new name is invalid ({@code INVALID_NAME}) *
  • A child in its associated container already exists with the same - * name and replace has been specified as false (NAME_COLLISION) - *
  • A container or element is read-only (READ_ONLY) + * name and {@code replace} has been specified as {@code false} + * ({@code NAME_COLLISION}) + *
  • A container or element is read-only ({@code READ_ONLY}) *
*/ - void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException; + void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, + boolean replace, IProgressMonitor monitor) throws CModelException; /** * Deletes the given elements, forcing the operation if necessary and specified. * * @param elements the elements to delete * @param force a flag controlling whether underlying resources that are not - * in sync with the local file system will be tolerated + * in sync with the local file system will be tolerated * @param monitor a progress monitor * @exception CModelException if an element could not be deleted. Reasons include: *
    *
  • A specified element does not exist (ELEMENT_DOES_NOT_EXIST)
  • - *
  • A CoreException occurred while updating an underlying resource - *
  • An element is read-only (READ_ONLY) + *
  • A {@code CoreException} occurred while updating an underlying resource + *
  • An element is read-only ({@code READ_ONLY}) *
*/ void delete(ICElement[] elements, boolean force, IProgressMonitor monitor) throws CModelException; @@ -101,46 +99,45 @@ * its associated container. *

* Optionally, each element can positioned before a sibling - * element. If null is specified for sibling, the element + * element. If {@code null} is specified for sibling, the element * is inserted as the last child of its associated container. - *

*

* Optionally, each element can be renamed. If - * null is specified for the new name, the element + * {@code null} is specified for the new name, the element * is not renamed. - *

*

* Optionally, any existing child in the destination container with - * the same name can be replaced by specifying true for + * the same name can be replaced by specifying {@code true} for * force. Otherwise an exception is thrown in the event that a name * collision occurs. - *

* * @param elements the elements to move * @param containers the container, or list of containers * @param siblings the list of siblings element any of which may be - * null; or null + * {@code null}; or {@code null} * @param renamings the list of new names any of which may be - * null; or null - * @param replace true if any existing child in a target container - * with the target name should be replaced, and false to throw an - * exception in the event of a name collision + * {@code null}; or {@code null} + * @param replace {@code true} if any existing child in a target container + * with the target name should be replaced, and {@code false} to throw an + * exception in the event of a name collision * @param monitor a progress monitor * @exception CModelException if an element could not be moved. Reasons include: *
    *
  • A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)
  • - *
  • A CoreException occurred while updating an underlying resource - *
  • A container is of an incompatible type (INVALID_DESTINATION) - *
  • A sibling is not a child of it associated container (INVALID_SIBLING) - *
  • A new name is invalid (INVALID_NAME) + *
  • A {@code CoreException} occurred while updating an underlying resource + *
  • A container is of an incompatible type ({@code INVALID_DESTINATION}) + *
  • A sibling is not a child of it associated container ({@code INVALID_SIBLING}) + *
  • A new name is invalid ({@code INVALID_NAME}) *
  • A child in its associated container already exists with the same - * name and replace has been specified as false (NAME_COLLISION) - *
  • A container or element is read-only (READ_ONLY) + * name and {@code replace} has been specified as {@code false} + * ({@code NAME_COLLISION}) + *
  • A container or element is read-only ({@code READ_ONLY}) *
* - * @exception IllegalArgumentException any element or container is null + * @exception IllegalArgumentException any element or container is {@code null} */ - void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException; + void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, + boolean replace, IProgressMonitor monitor) throws CModelException; /** * Renames the given elements as specified. @@ -152,46 +149,44 @@ * @param elements the elements to rename * @param destinations the container, or list of containers * @param names the list of new names - * @param replace true if an existing child in a target container - * with the target name should be replaced, and false to throw an - * exception in the event of a name collision + * @param replace {@code true} if an existing child in a target container + * with the target name should be replaced, and {@code false} to throw an + * exception in the event of a name collision * @param monitor a progress monitor * @exception CModelException if an element could not be renamed. Reasons include: *
    *
  • A specified element does not exist (ELEMENT_DOES_NOT_EXIST)
  • - *
  • A CoreException occurred while updating an underlying resource - *
  • A new name is invalid (INVALID_NAME) - *
  • A child already exists with the same name and replace has been specified as false (NAME_COLLISION) - *
  • An element is read-only (READ_ONLY) + *
  • A {@code CoreException} occurred while updating an underlying resource + *
  • A new name is invalid ({@code INVALID_NAME}) + *
  • A child already exists with the same name and {@code replace} has been specified as + * {@code false} ({@code NAME_COLLISION}) + *
  • An element is read-only ({@code READ_ONLY}) *
*/ - void rename(ICElement[] elements, ICElement[] destinations, String[] names, boolean replace, IProgressMonitor monitor) throws CModelException; + void rename(ICElement[] elements, ICElement[] destinations, String[] names, boolean replace, + IProgressMonitor monitor) throws CModelException; /** * Returns the C project with the given name. This is a handle-only method. * The project may or may not exist. * - * @param name of the Project + * @param name of the project */ ICProject getCProject(String name); /** * Returns the C projects. - * */ ICProject[] getCProjects() throws CModelException; /** - * Returns an array of non-C resources (i.e. non-C projects) in - * the workspace. + * Returns an array of non-C resources (i.e. non-C projects) in the workspace. *

- * Non-C projects include all projects that are closed (even if they have the - * C nature). - *

- * + * Non-C projects include all projects that are closed (even if they have the C nature). + * * @return an array of non-C projects contained in the workspace. - * @throws CModelException if this element does not exist or if an - * exception occurs while accessing its corresponding resource + * @throws CModelException if this element does not exist or if an exception occurs + * while accessing its corresponding resource * @since 2.1 */ Object[] getNonCResources() throws CModelException; @@ -200,5 +195,4 @@ * Returns the workspace associated with this C model. */ IWorkspace getWorkspace(); - } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICProject.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICProject.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICProject.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICProject.java 2015-02-11 19:19:10.000000000 +0000 @@ -30,7 +30,6 @@ * @noimplement This interface is not intended to be implemented by clients. */ public interface ICProject extends IParent, IOpenable, ICElement { - /** * Returns the ICElement corresponding to the given * path, or null if no such @@ -67,8 +66,7 @@ * Returns all of the existing source roots that exist * on the project, in the order they are defined by the ".cdtproject". * - * @return all of the existing package fragment roots that exist - * on the classpath + * @return all of the existing source roots * @exception CModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource */ @@ -243,5 +241,4 @@ * exception occurs while accessing its corresponding resource */ Object[] getNonCResources() throws CModelException; - } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 QNX Software Systems and others. + * Copyright (c) 2000, 2014 QNX Software Systems 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 @@ -8,6 +8,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.model; @@ -21,6 +22,7 @@ import org.eclipse.cdt.core.parser.FileContent; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.internal.core.model.IBufferFactory; +import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -420,6 +422,15 @@ public IPath getLocation(); /** + * Returns the corresponding file for this translation unit, or {@code null} if this translation + * unit does not have a corresponding file. + * + * @return the corresponding file, or {@code null} if none + * @since 5.9 + */ + IFile getFile(); + + /** * Returns the scanner info associated with this translation unit. May return {@code null} * if no configuration is available. * diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java 2015-02-11 19:19:10.000000000 +0000 @@ -16,36 +16,22 @@ import org.eclipse.core.runtime.Path; public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry { -// IPath fFullPath; -// IPath fLocation; -// private IPath fPath; - /** - * Constructor. + * Creates an ACPathEntry. * * @param rc - a resource in the workspace. * @param flags - bitwise combination of {@link ICSettingEntry} flags. - * If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied. + * If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied. */ ACPathEntry(IResource rc, int flags) { super(rc.getFullPath().toString(), flags | RESOLVED | VALUE_WORKSPACE_PATH); -// fFullPath = rc.getFullPath(); -// fPath = rc.getFullPath(); -// fLocation = rc.getLocation(); } -/* public ACLanguageSettingPathEntry(IPath fullPath, IPath location, int flags) { - super(flags); - fLocation = location; - fFullPath = fullPath; - } -*/ - /** - * Constructor. + * Creates an ACPathEntry. * * @param name - resource path. The path can be an absolute location on the local file-system - * or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. * @param flags - bitwise combination of {@link ICSettingEntry} flags. */ ACPathEntry(String name, int flags) { @@ -61,11 +47,6 @@ */ ACPathEntry(IPath path, int flags) { super(path.toString(), flags /*| RESOLVED*/); -// fPath = path; -// if (isValueWorkspacePath()) -// fFullPath = path; -// else -// fLocation = path; } @Override @@ -81,8 +62,8 @@ protected IPath fullPathForLocation(IPath location){ IResource rcs[] = isFile() ? - (IResource[])ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location) - : (IResource[])ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location); + (IResource[]) ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location) : + (IResource[]) ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location); if (rcs.length > 0) return rcs[0].getFullPath(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSourceEntry.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSourceEntry.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSourceEntry.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSourceEntry.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,10 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Intel Corporation - Initial API and implementation + * Intel Corporation - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.settings.model; - public interface ICSourceEntry extends ICExclusionPatternPathEntry{ } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICStorageElement.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICStorageElement.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICStorageElement.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICStorageElement.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,21 +6,20 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Intel Corporation - Initial API and implementation - * James Blackburn (Broadcom Corp.) + * Intel Corporation - Initial API and implementation + * James Blackburn (Broadcom Corp.) *******************************************************************************/ package org.eclipse.cdt.core.settings.model; import org.eclipse.core.runtime.CoreException; - /** - * * This interface represents an generic element in a storage tree. These trees are rooted at - * {@link ICSettingsStorage} Elements. + * {@link ICSettingsStorage} elements. * - * This abstract storage mechanism is used, e.g. with the {@link ICProjectDescription} and {@link ICConfigurationDescription} - * for storing custom data in the settings file (.cproject) or in a database + * This abstract storage mechanism is used, e.g. with the {@link ICProjectDescription} and + * {@link ICConfigurationDescription} for storing custom data in the settings file (.cproject) + * or in a database. * * @see ICSettingsStorage * @see ICProjectDescription @@ -29,7 +28,6 @@ * @noimplement This interface is not intended to be implemented by clients. */ public interface ICStorageElement { - /** * Return the String of attribute value for name. * If attribute is not found (hasAttribute(name) is false) @@ -50,7 +48,6 @@ /** * Returns a string array of attribute names - * @return String[] */ String[] getAttributeNames(); @@ -104,25 +101,23 @@ boolean hasChildren(); /** - * Erase all children, attributes and any value set on this ICStorageElement + * Erases all children, attributes and any value set on this ICStorageElement */ void clear(); /** - * Get the name of this ICStorageElement - * @return String name + * Returns the name of this ICStorageElement */ String getName(); /** - * Remove the ICStorageElement from the set of child ICSotrageElements + * Removes the ICStorageElement from the set of child ICSotrageElements * @param el */ void removeChild(ICStorageElement el); /** - * Get the String value of this element or null if there is - * no String value set. + * Returns the String value of this element or null if there is no String value set. * * NB a pure whitespace value is considered to be null * @return String or null @@ -130,18 +125,17 @@ String getValue(); /** - * Set a String value on the ICStorageElement + * Sets a String value on the ICStorageElement * @param value */ void setValue(String value); /** - * Import an existing ICStorageElemtn as a child of this ICStorageElement - * @param el - * @return ICStorageElement a Handle on the newly imported ICStorageElement - * @throws UnsupportedOperationException + * Imports an existing ICStorageElemtn as a child of this ICStorageElement + * @param element + * @return ICStorageElement a handle on the newly imported ICStorageElement */ - ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException; + ICStorageElement importChild(ICStorageElement element) throws UnsupportedOperationException; /** * Create a deep copy of the current ICStorageElement such that name, children, attributes and value @@ -159,20 +153,6 @@ ICStorageElement createCopy() throws UnsupportedOperationException, CoreException; /** - * Returns an ICSettingsStorage from this storage element. - * - * A setting storage is like a storage element except it represents the root of a tree. - * As such it can't contain a value or any children which are not storageModule - * ICStorageElements (otherwise they would not be accessible via the ICSettingsStorage interface) - * - * @param readOnly indicates whether the returned settings storage tree should be readonly - * @return ICSettingStorage which is this ICStorageElement as a storageModule root - * @throws CoreException if this ICStorageElement isn't a suitable root - * @throws UnsupportedOperationException if this hierarchy doesn't support ICSettingsStorage - */ -// ICSettingsStorage createSettingStorage(boolean readOnly) throws CoreException, UnsupportedOperationException; - - /** * Tests whether this storage element is exactly equal to other * To be equal all name, children attributes and value must be * equal between the two ICStorageElements diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java 2015-02-11 19:19:10.000000000 +0000 @@ -9,6 +9,7 @@ * Anton Leherbauer (Wind River Systems) - initial API and implementation * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) + * Marc-Andre Laperle (Ericsson) *******************************************************************************/ package org.eclipse.cdt.internal.core.model; @@ -59,6 +60,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression; @@ -314,6 +316,17 @@ if (cppFunctionDecl.isVolatile()) { buffer.append(Keywords.VOLATILE).append(' '); } + RefQualifier refQualifier = cppFunctionDecl.getRefQualifier(); + if (refQualifier != null) { + switch (refQualifier) { + case LVALUE: + buffer.append(Keywords.cpAMPER).append(' '); + break; + case RVALUE: + buffer.append(Keywords.cpAND).append(' '); + break; + } + } if (cppFunctionDecl.isPureVirtual()) { buffer.append("=0 "); //$NON-NLS-1$ } @@ -442,7 +455,11 @@ buffer.append(' ').append(Keywords.RESTRICT); } } else if (pointerOperator instanceof ICPPASTReferenceOperator) { - buffer.append(Keywords.cpAMPER); + if (((ICPPASTReferenceOperator) pointerOperator).isRValueReference()) { + buffer.append(Keywords.cpAND); + } else { + buffer.append(Keywords.cpAMPER); + } } } return buffer; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainer.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainer.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainer.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainer.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2015 QNX Software Systems 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 @@ -48,11 +48,6 @@ super(parent, res, type); } - /** - * Returns a the collection of binary files in this ccontainer - * - * @see ICContainer#getBinaries() - */ @Override public IBinary[] getBinaries() throws CModelException { List list = getChildrenOfType(C_BINARY); @@ -61,9 +56,6 @@ return array; } - /** - * @see ICContainer#getBinary(String) - */ @Override public IBinary getBinary(String name) { IFile file = getContainer().getFile(new Path(name)); @@ -78,11 +70,6 @@ return new Binary(this, file, null); } - /** - * Returns a the collection of archive files in this ccontainer - * - * @see ICContainer#getArchives() - */ @Override public IArchive[] getArchives() throws CModelException { List list = getChildrenOfType(C_ARCHIVE); @@ -91,9 +78,6 @@ return array; } - /** - * @see ICContainer#getArchive(String) - */ @Override public IArchive getArchive(String name) { IFile file = getContainer().getFile(new Path(name)); @@ -108,9 +92,6 @@ return new Archive(this, file, null); } - /** - * @see ICContainer#getTranslationUnits() - */ @Override public ITranslationUnit[] getTranslationUnits() throws CModelException { List list = getChildrenOfType(C_UNIT); @@ -119,11 +100,6 @@ return array; } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.model.ICContainer#getTranslationUnit(java.lang.String) - */ @Override public ITranslationUnit getTranslationUnit(String name) { IFile file = getContainer().getFile(new Path(name)); @@ -135,11 +111,6 @@ return new TranslationUnit(this, file, id); } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.model.ICContainer#getCContainers() - */ @Override public ICContainer[] getCContainers() throws CModelException { List list = getChildrenOfType(C_CCONTAINER); @@ -148,11 +119,6 @@ return array; } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.model.ICContainer#getCContainer(java.lang.String) - */ @Override public ICContainer getCContainer(String name) { IFolder folder = getContainer().getFolder(new Path(name)); @@ -164,7 +130,7 @@ } public IContainer getContainer() { - return (IContainer) getResource(); + return getResource(); } @Override @@ -178,9 +144,6 @@ return getPath().hashCode(); } - /** - * @see Openable - */ @Override protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException { @@ -200,19 +163,13 @@ return validInfo; } - /* - * (non-Javadoc) Returns an array of non-c resources contained in the - * receiver. - * - * @see org.eclipse.cdt.core.model.ICContainer#getNonCResources() - */ @Override public Object[] getNonCResources() throws CModelException { return ((CContainerInfo) getElementInfo()).getNonCResources(getResource()); } protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException { - ArrayList vChildren = new ArrayList(); + ArrayList vChildren = new ArrayList<>(); try { IResource[] resources = null; if (res instanceof IContainer) { @@ -221,8 +178,8 @@ } if (resources != null) { ICProject cproject = getCProject(); - for (IResource resource2 : resources) { - ICElement celement = computeChild(resource2, cproject); + for (IResource resource : resources) { + ICElement celement = computeChild(resource, cproject); if (celement != null) { vChildren.add(celement); } @@ -301,7 +258,7 @@ name = ""; //$NON-NLS-1$ token = null; } - CElement folder = (CElement)getCContainer(name); + CElement folder = (CElement) getCContainer(name); if (folder != null) { if (token == null) { return folder.getHandleFromMemento(memento); @@ -311,7 +268,8 @@ } break; case CEM_TRANSLATIONUNIT: - if (!memento.hasMoreTokens()) return this; + if (!memento.hasMoreTokens()) + return this; String tuName = memento.nextToken(); CElement tu = (CElement) getTranslationUnit(tuName); if (tu != null) { @@ -326,4 +284,8 @@ return CElement.CEM_SOURCEFOLDER; } + @Override + public IContainer getResource() { + return (IContainer) super.getResource(); + } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.java 2015-02-11 19:19:10.000000000 +0000 @@ -10,14 +10,13 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.model; -import com.ibm.icu.text.MessageFormat; import java.util.MissingResourceException; import java.util.ResourceBundle; +import com.ibm.icu.text.MessageFormat; /** - * CoreModelMessages - * + * @noreference This class is not intended to be referenced by clients. */ public class CoreModelMessages { private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.core.model.CoreModelMessages"; //$NON-NLS-1$ @@ -44,29 +43,27 @@ } /** - * Gets a string from the resource bundle and formats it with the argument + * Returns a string from the resource bundle and formats it with the argument * - * @param key the string used to get the bundle value, must not be null + * @param key the string used to get the bundle value, must not be {@code null} */ public static String getFormattedString(String key) { return getString(key); } - /** - * Gets a string from the resource bundle and formats it with the argument + * Returns a string from the resource bundle and formats it with the argument * - * @param key the string used to get the bundle value, must not be null + * @param key the string used to get the bundle value, must not be {@code null} */ public static String getFormattedString(String key, Object arg) { return MessageFormat.format(getString(key), new Object[] { arg }); } /** - * Gets a string from the resource bundle and formats it with arguments + * Returns a string from the resource bundle and formats it with arguments */ public static String getFormattedString(String key, Object[] args) { return MessageFormat.format(getString(key), args); } - } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties 2015-02-11 19:19:10.000000000 +0000 @@ -6,9 +6,9 @@ # http://www.eclipse.org/legal/epl-v10.html # # Contributors: -# QNX Software Systems - Initial API and implementation -# Anton Leherbauer (Wind River Systems) -# Markus Schorn (Wind River Systems) +# QNX Software Systems - Initial API and implementation +# Anton Leherbauer (Wind River Systems) +# Markus Schorn (Wind River Systems) ############################################################################### ### CoreModel messages. diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java 2015-02-11 19:19:10.000000000 +0000 @@ -65,7 +65,6 @@ import org.osgi.service.prefs.BackingStoreException; public class CProject extends Openable implements ICProject { - private static final String CUSTOM_DEFAULT_OPTION_VALUE = "#\r\n\r#custom-non-empty-default-value#\r\n\r#"; //$NON-NLS-1$ public CProject(ICElement parent, IProject project) { @@ -593,9 +592,9 @@ ArrayList list = new ArrayList<>(entries.length); for (ICSourceEntry sourceEntry : entries) { ISourceRoot root = getSourceRoot(sourceEntry); - if (root != null) { - list.add(root); - } + if (root != null) { + list.add(root); + } } return list; } @@ -746,7 +745,8 @@ } break; case CEM_TRANSLATIONUNIT: - if (!memento.hasMoreTokens()) return this; + if (!memento.hasMoreTokens()) + return this; String tuName = memento.nextToken(); final IPath path= Path.fromPortableString(tuName); CElement tu= null; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateWorkingCopyOperation.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateWorkingCopyOperation.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateWorkingCopyOperation.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateWorkingCopyOperation.java 2015-02-11 19:19:10.000000000 +0000 @@ -46,11 +46,11 @@ WorkingCopy workingCopy; if (tu.getResource() != null) { - workingCopy= new WorkingCopy(tu.getParent(), (IFile)tu.getResource(), tu.getContentTypeId(), this.factory, this.problemRequestor); + workingCopy= new WorkingCopy(tu.getParent(), (IFile) tu.getResource(), tu.getContentTypeId(), this.factory, this.problemRequestor); } else { workingCopy= new WorkingCopy(tu.getParent(), tu.getLocationURI(), tu.getContentTypeId(), this.factory); } - // open the working copy now to ensure contents are that of the current state of this element + // Open the working copy now to ensure contents are that of the current state of this element. // Alain: Actually no, delay the parsing 'till it is really needed. Doing the parsing here // really slows down the opening of the CEditor. //workingCopy.open(this.fMonitor); @@ -62,7 +62,7 @@ //} } - // report added java delta + // Report added C delta. CElementDelta delta = new CElementDelta(this.getCModel()); delta.added(workingCopy); addDelta(delta); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/InternalCoreModelUtil.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/InternalCoreModelUtil.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/InternalCoreModelUtil.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/InternalCoreModelUtil.java 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2010, 2014 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.model; + +import static org.eclipse.cdt.core.model.CoreModelUtil.isExcludedPath; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.core.model.ISourceEntry; +import org.eclipse.cdt.core.settings.model.CSourceEntry; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICSourceEntry; +import org.eclipse.cdt.core.settings.model.WriteAccessException; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; + +/** + * Non-API methods for manipulating C/C++ projects. + */ +public class InternalCoreModelUtil { + public static void addSourceEntry(IProject project, IFolder folder, boolean removeProject, + IProgressMonitor monitor) throws CoreException { + ICSourceEntry newEntry = new CSourceEntry(folder, null, 0); + ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, true); + addEntryToAllCfgs(des, newEntry, removeProject); + CCorePlugin.getDefault().setProjectDescription(project, des, false, monitor); + } + + private static void addEntryToAllCfgs(ICProjectDescription des, ICSourceEntry entry, + boolean removeProject) throws WriteAccessException, CoreException { + ICConfigurationDescription cfgs[] = des.getConfigurations(); + for (ICConfigurationDescription cfg : cfgs) { + ICSourceEntry[] entries = cfg.getSourceEntries(); + entries = addEntry(entries, entry, removeProject); + cfg.setSourceEntries(entries); + } + } + + private static ICSourceEntry[] addEntry(ICSourceEntry[] entries, ICSourceEntry sourceEntry, + boolean removeProject) { + Set set = new HashSet<>(); + for (ICSourceEntry entry : entries) { + if (removeProject && new Path(entry.getValue()).segmentCount() == 1) + continue; + set.add(entry); + } + set.add(sourceEntry); + return set.toArray(new ICSourceEntry[set.size()]); + } + + public static void addExclusionPatterns(IPathEntry newEntry, List existing, + Set modifiedEntries) { + IPath entryPath= newEntry.getPath(); + for (int i= 0; i < existing.size(); i++) { + IPathEntry curr= existing.get(i); + IPath currPath= curr.getPath(); + if (curr.getEntryKind() == IPathEntry.CDT_SOURCE && currPath.isPrefixOf(entryPath)) { + IPath[] exclusionFilters= ((ISourceEntry) curr).getExclusionPatterns(); + if (!isExcludedPath(entryPath, exclusionFilters)) { + IPath pathToExclude= entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator(); + IPath[] newExclusionFilters= new IPath[exclusionFilters.length + 1]; + System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length); + newExclusionFilters[exclusionFilters.length]= pathToExclude; + + IPathEntry updated= CoreModel.newSourceEntry(currPath, newExclusionFilters); + existing.set(i, updated); + modifiedEntries.add(updated); + } + } + } + } +} diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java 2015-02-11 19:19:10.000000000 +0000 @@ -81,7 +81,7 @@ Map newElements, IResource underlyingResource) throws CModelException; /** - * Close the buffer associated with this element, if any. + * Closes the buffer associated with this element, if any. */ protected void closeBuffer() { if (!hasBuffer()) return; // nothing to do @@ -94,7 +94,7 @@ } /** - * This element is being closed. Do any necessary cleanup. + * Does any necessary cleanup when this element is being closed. */ @Override protected void closing(Object info) throws CModelException { @@ -107,13 +107,13 @@ @Override public IBuffer getBuffer() throws CModelException { if (hasBuffer()) { - // ensure element is open + // Ensure element is open. if (!isOpen()) { getElementInfo(); } IBuffer buffer = getBufferManager().getBuffer(this); if (buffer == null) { - // try to (re)open a buffer + // Try to (re)open a buffer. buffer = openBuffer(null); } return buffer; @@ -122,7 +122,7 @@ } /** - * Answers the buffer factory to use for creating new buffers + * Returns the buffer factory to use for creating new buffers. */ public IBufferFactory getBufferFactory(){ return getBufferManager().getDefaultBufferFactory(); @@ -142,9 +142,7 @@ protected boolean hasBuffer() { return false; } - /** - * @see org.eclipse.cdt.core.model.IOpenable#hasUnsavedChanges() - */ + @Override public boolean hasUnsavedChanges() throws CModelException{ if (isReadOnly() || !isOpen()) { @@ -154,8 +152,8 @@ if (buf != null && buf.hasUnsavedChanges()) { return true; } - // for roots and projects must check open buffers - // to see if they have an child with unsaved changes + // For roots and projects must check open buffers to see + // if they have an child with unsaved changes. if (fType == C_MODEL || fType == C_PROJECT) { Enumeration openBuffers= getBufferManager().getOpenBuffers(); while (openBuffers.hasMoreElements()) { @@ -182,9 +180,6 @@ return true; } - /** - * @see org.eclipse.cdt.core.model.IOpenable#isOpen() - */ @Override public boolean isOpen() { return CModelManager.getDefault().getInfo(this) != null; @@ -197,9 +192,8 @@ } /** - * Returns true if this represents a source element. - * Openable source elements have an associated buffer created - * when they are opened. + * Returns true if this represents a source element. Openable source elements have + * an associated buffer created when they are opened. */ protected boolean isSourceElement() { return false; @@ -215,13 +209,10 @@ @Override public void makeConsistent(IProgressMonitor monitor, boolean forced) throws CModelException { - // only translation units can be inconsistent - // other openables cannot be inconsistent so default is to do nothing + // Only translation units can be inconsistent. + // Other Openables cannot be inconsistent so default is to do nothing. } - /** - * @see org.eclipse.cdt.core.model.IOpenable#open(IProgressMonitor) - */ @Override public void open(IProgressMonitor pm) throws CModelException { getElementInfo(pm); @@ -248,9 +239,6 @@ } } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected void generateInfos(CElementInfo info, Map newElements, IProgressMonitor monitor) throws CModelException { @@ -258,16 +246,16 @@ System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$ } - // open the parent if necessary + // Open the parent if necessary. openParent(info, newElements, monitor); if (monitor != null && monitor.isCanceled()) return; - // puts the info before building the structure so that questions to the handle behave as if the element existed - // (case of compilation units becoming working copies) + // Put the info before building the structure so that questions to the handle behave as if + // the element existed (case of compilation units becoming working copies). newElements.put(this, info); - // build the structure of the openable (this will open the buffer if needed) + // Build the structure of the Openable (this will open the buffer if needed). try { OpenableInfo openableInfo = (OpenableInfo) info; boolean isStructureKnown = buildStructure(openableInfo, monitor, newElements, getResource()); @@ -277,13 +265,10 @@ throw e; } - // remove out of sync buffer for this element + // Remove out of sync buffer for this element. CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this); } - /** - * @see org.eclipse.cdt.core.model.IOpenable#save(IProgressMonitor, boolean) - */ @Override public void save(IProgressMonitor pm, boolean force) throws CModelException { IResource res = getResource(); @@ -293,7 +278,7 @@ throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); } } - // check also the underlying resource + // Check also the underlying resource. if (isReadOnly()) { throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); } @@ -305,7 +290,7 @@ } /** - * Find enclosing package fragment root if any + * Finds enclosing package fragment root if any. */ public SourceRoot getSourceRoot() { ICElement current = this; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 QNX Software Systems and others. + * Copyright (c) 2000, 2015 QNX Software Systems 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 @@ -47,10 +47,13 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.preferences.DefaultScope; public class PathEntryUtil { - static PathEntryManager manager = PathEntryManager.getDefault(); + static final PathEntryManager manager = PathEntryManager.getDefault(); static final IMarker[] NO_MARKERS = new IMarker[0]; + static final boolean VALIDATE_INCLUDE_ENTRIES = + DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).getBoolean("validate_include_entries", true); //$NON-NLS-1$ private PathEntryUtil() { super(); @@ -426,15 +429,17 @@ switch (entry.getEntryKind()) { case IPathEntry.CDT_INCLUDE: { - IIncludeEntry include = (IIncludeEntry) entry; - IPath includePath = include.getFullIncludePath(); - if (!isValidExternalPath(includePath)) { - return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, - CoreModelMessages.getFormattedString("PathEntryManager.2", includePath.toOSString())); //$NON-NLS-1$ - } - if (!isValidBasePath(include.getBasePath())) { - return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, - CoreModelMessages.getFormattedString("PathEntryManager.1", includePath.toOSString())); //$NON-NLS-1$ + if (VALIDATE_INCLUDE_ENTRIES) { + IIncludeEntry include = (IIncludeEntry) entry; + IPath includePath = include.getFullIncludePath(); + if (!isValidExternalPath(includePath)) { + return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, + CoreModelMessages.getFormattedString("PathEntryManager.2", includePath.toOSString())); //$NON-NLS-1$ + } + if (!isValidBasePath(include.getBasePath())) { + return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, + CoreModelMessages.getFormattedString("PathEntryManager.1", includePath.toOSString())); //$NON-NLS-1$ + } } break; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java 2015-02-11 19:19:10.000000000 +0000 @@ -23,7 +23,7 @@ @Override public boolean equals (Object obj) { if (obj instanceof ISourceEntry) { - ISourceEntry otherEntry = (ISourceEntry)obj; + ISourceEntry otherEntry = (ISourceEntry) obj; if (!super.equals(otherEntry)) { return false; } @@ -40,5 +40,4 @@ } return super.equals(obj); } - } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulationInfo.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulationInfo.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulationInfo.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulationInfo.java 2015-02-11 19:19:10.000000000 +0000 @@ -24,9 +24,7 @@ /** * Element info for ISourceReference elements. */ -/* package */ class SourceManipulationInfo extends CElementInfo { - protected int fStartPos; protected int fLength; protected int fIdStartPos; @@ -79,16 +77,11 @@ } protected ISourceRange getSourceRange() { - return new SourceRange(fStartPos, - fLength, - fIdStartPos, - fIdLength, - fStartLine, - fEndLine); + return new SourceRange(fStartPos, fLength, fIdStartPos, fIdLength, fStartLine, fEndLine); } /** - * @see ISourceReference + * @see ISourceReference#getSource() */ public String getSource() throws CModelException { ITranslationUnit unit = getTranslationUnit(); @@ -103,7 +96,7 @@ } try { return buffer.getText(offset, length); - } catch(RuntimeException e) { + } catch (RuntimeException e) { return null; } @@ -127,93 +120,90 @@ } /** - * @see IMember + * @see IMember#getTranslationUnit() */ public ITranslationUnit getTranslationUnit() { - ICElement celem = getElement(); - for (; celem != null; celem = celem.getParent()) { + for (ICElement celem = getElement(); celem != null; celem = celem.getParent()) { if (celem instanceof ITranslationUnit) - return (ITranslationUnit)celem; + return (ITranslationUnit) celem; } return null; } /** - * @see ISourceManipulation + * @see ISourceManipulation#copy(ICElement, ICElement, String, boolean, IProgressMonitor) */ public void copy(ICElement container, ICElement sibling, String rename, boolean force, IProgressMonitor monitor) throws CModelException { if (container == null) { throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$ } - ICElement[] elements= new ICElement[] {getElement()}; - ICElement[] containers= new ICElement[] {container}; + ICElement[] elements= new ICElement[] { getElement() }; + ICElement[] containers= new ICElement[] { container }; ICElement[] siblings= null; if (sibling != null) { - siblings= new ICElement[] {sibling}; + siblings= new ICElement[] { sibling }; } String[] renamings= null; if (rename != null) { - renamings= new String[] {rename}; + renamings= new String[] { rename }; } getElement().getCModel().copy(elements, containers, siblings, renamings, force, monitor); } /** - * @see ISourceManipulation + * @see ISourceManipulation#delete(boolean, IProgressMonitor) */ public void delete(boolean force, IProgressMonitor monitor) throws CModelException { - ICElement[] elements = new ICElement[] {getElement()}; + ICElement[] elements = new ICElement[] { getElement() }; getElement().getCModel().delete(elements, force, monitor); } /** - * @see ISourceManipulation + * @see ISourceManipulation#move(ICElement, ICElement, String, boolean, IProgressMonitor) */ public void move(ICElement container, ICElement sibling, String rename, boolean force, - IProgressMonitor monitor) throws CModelException { + IProgressMonitor monitor) throws CModelException { if (container == null) { throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$ } - ICElement[] elements= new ICElement[] {getElement()}; - ICElement[] containers= new ICElement[] {container}; + ICElement[] elements= new ICElement[] { getElement() }; + ICElement[] containers= new ICElement[] { container }; ICElement[] siblings= null; if (sibling != null) { - siblings= new ICElement[] {sibling}; + siblings= new ICElement[] { sibling }; } String[] renamings= null; if (rename != null) { - renamings= new String[] {rename}; + renamings= new String[] { rename }; } getElement().getCModel().move(elements, containers, siblings, renamings, force, monitor); } /** - * @see ISourceManipulation + * @see ISourceManipulation#rename(String, boolean, IProgressMonitor) */ public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException { if (name == null) { throw new IllegalArgumentException("element.nullName"); //$NON-NLS-1$ } - ICElement[] elements= new ICElement[] {getElement()}; - ICElement[] dests= new ICElement[] {getElement().getParent()}; - String[] renamings= new String[] {name}; + ICElement[] elements= new ICElement[] { getElement() }; + ICElement[] dests= new ICElement[] { getElement().getParent() }; + String[] renamings= new String[] { name }; getElement().getCModel().rename(elements, dests, renamings, force, monitor); } /** - * return the element modifiers - * @return int + * Returns the element modifiers. */ - public int getModifiers(){ + public int getModifiers() { return 0; } /** - * subclasses should override + * Subclasses should override */ - public boolean hasSameContentsAs( SourceManipulationInfo otherInfo){ - return (this.element.fType == otherInfo.element.fType); + public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) { + return element.fType == otherInfo.element.fType; } - } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceRoot.java 2015-02-11 19:19:10.000000000 +0000 @@ -25,10 +25,6 @@ public class SourceRoot extends CContainer implements ISourceRoot { ICSourceEntry sourceEntry; - /** - * @param parent - * @param res - */ public SourceRoot(ICElement parent, IResource res, ICSourceEntry entry) { super(parent, res); sourceEntry = entry; @@ -78,7 +74,7 @@ } else { path= Path.EMPTY; } - ((CElement)getParent()).getHandleMemento(buff); + ((CElement) getParent()).getHandleMemento(buff); buff.append(getHandleMementoDelimiter()); escapeMementoName(buff, path.toString()); } @@ -90,5 +86,4 @@ protected char getHandleMementoDelimiter() { return CElement.CEM_SOURCEROOT; } - } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 QNX Software Systems and others. + * Copyright (c) 2000, 2014 QNX Software Systems 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 @@ -84,12 +84,14 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.osgi.util.NLS; /** * @see ITranslationUnit @@ -354,8 +356,9 @@ return location; } + @Override public IFile getFile() { - IResource res = getResource(); + IResource res = super.getResource(); if (res instanceof IFile) { return (IFile) res; } @@ -370,17 +373,20 @@ @Override public void delete(boolean force, IProgressMonitor monitor) throws CModelException { + Assert.isTrue(!isReadOnly(), NLS.bind("Translation unit {0} must not be read-only", getElementName())); //$NON-NLS-1$ getSourceManipulationInfo().delete(force, monitor); } @Override public void move(ICElement container, ICElement sibling, String rename, boolean force, IProgressMonitor monitor) throws CModelException { + Assert.isTrue(!isReadOnly(), NLS.bind("Translation unit {0} must not be read-only", getElementName())); //$NON-NLS-1$ getSourceManipulationInfo().move(container, sibling, rename, force, monitor); } @Override public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException { + Assert.isTrue(!isReadOnly(), NLS.bind("Translation unit {0} must not be read-only", getElementName())); //$NON-NLS-1$ getSourceManipulationInfo().rename(name, force, monitor); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java 2015-02-11 19:19:10.000000000 +0000 @@ -43,23 +43,23 @@ */ protected IBufferFactory bufferFactory; /** - * A counter of the number of time clients have asked for this - * working copy. It is set to 1, if the working - * copy is not managed. When destroyed, this counter is - * set to 0. Once destroyed, this working copy cannot be opened - * and non-handle info can not be accessed. This is - * never true if this translation unit is not a working copy. + * A counter of the number of time clients have asked for this working copy. + * It is set to 1, if the working copy is not managed. When destroyed, this + * counter is set to 0. Once destroyed, this working copy cannot be opened + * and non-handle info can not be accessed. This is never true if this + * translation unit is not a working copy. */ protected int useCount = 1; /** - * Creates a working copy of this element + * Creates a working copy of this element. */ public WorkingCopy(ICElement parent, IFile file, String id, IBufferFactory bufferFactory) { this(parent, file, id, bufferFactory, null); } - public WorkingCopy(ICElement parent, IFile file, String id, IBufferFactory bufferFactory, IProblemRequestor requestor) { + public WorkingCopy(ICElement parent, IFile file, String id, IBufferFactory bufferFactory, + IProblemRequestor requestor) { super(parent, file, id); this.bufferFactory = bufferFactory == null ? getBufferManager() : bufferFactory; problemRequestor = requestor; @@ -156,7 +156,7 @@ public ICElement getOriginal(ICElement workingCopyElement) { // It has to come from the same workingCopy, meaning ours. if (workingCopyElement instanceof ISourceReference) { - ITranslationUnit wunit = ((ISourceReference)workingCopyElement).getTranslationUnit(); + ITranslationUnit wunit = ((ISourceReference) workingCopyElement).getTranslationUnit(); if (!wunit.equals(this)) { return null; } @@ -170,7 +170,7 @@ // Look for it. ICElement element = workingCopyElement; - ArrayList children = new ArrayList(); + ArrayList children = new ArrayList<>(); while (element != null && element.getElementType() != ICElement.C_UNIT) { children.add(element); element = element.getParent(); @@ -180,7 +180,7 @@ ICElement child = children.get(i); if (current instanceof IParent) { try { - ICElement[] celems = ((IParent)current).getChildren(); + ICElement[] celems = ((IParent) current).getChildren(); current = null; for (int j = 0; j < celems.length; ++j) { if (celems[j].getElementName().equals(child.getElementName()) && @@ -232,7 +232,7 @@ return false; } try { - // If resource got deleted, then #getModificationStamp() will answer + // If resource got deleted, then getModificationStamp() will answer // IResource.NULL_STAMP, which is always different from the cached timestamp. return ((TranslationUnitInfo) getElementInfo()).fTimestamp == ((IFile) resource).getModificationStamp(); } catch (CModelException e) { @@ -250,8 +250,8 @@ * @see IWorkingCopy * * @exception CModelException attempting to open a read only element for - * something other than navigation, or if this is a working copy being - * opened after it has been destroyed. + * something other than navigation, or if this is a working copy being + * opened after it has been destroyed. */ @Override public void open(IProgressMonitor monitor) throws CModelException { @@ -272,19 +272,19 @@ if (this.useCount == 0) throw newNotPresentException(); - // Create buffer - working copies may use custom buffer factory + // Create buffer - working copies may use custom buffer factory. IBuffer buffer = getBufferFactory().createBuffer(this); if (buffer == null) return null; - // Set the buffer source if needed + // Set the buffer source if needed. if (buffer.getContents() == null) { ITranslationUnit original= this.getOriginalElement(); IBuffer originalBuffer = null; try { originalBuffer = original.getBuffer(); } catch (CModelException e) { - // Original element does not exist: create an empty working copy + // Original element does not exist: create an empty working copy. if (!e.getCModelStatus().doesNotExist()) { throw e; } @@ -295,15 +295,15 @@ buffer.setContents(originalContents.clone()); } } else { - // Initialize buffer + // Initialize buffer. buffer.setContents(new char[0]); } } - // Add buffer to buffer cache + // Add buffer to buffer cache. this.getBufferManager().addBuffer(buffer); - // Listen to buffer changes + // Listen to buffer changes. buffer.addBufferChangedListener(this); return buffer; @@ -323,7 +323,7 @@ @Override public void restore() throws CModelException{ if (this.useCount == 0) - throw newNotPresentException(); // Was destroyed + throw newNotPresentException(); // Was destroyed. TranslationUnit original = (TranslationUnit) getOriginalElement(); IBuffer buffer = this.getBuffer(); @@ -338,15 +338,11 @@ if (isReadOnly()) { throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); } - // Computes fine-grain deltas in case the working copy is being reconciled already + // Compute fine-grain deltas in case the working copy is being reconciled already // (if not it would miss one iteration of deltas). this.reconcile(); } - /** - * @param original - * @throws CModelException - */ protected void updateTimeStamp(TranslationUnit original) throws CModelException { long timeStamp = ((IFile) original.getResource()).getModificationStamp(); if (timeStamp == IResource.NULL_STAMP) { @@ -356,12 +352,13 @@ } @Override - public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor) - throws CModelException { + public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, + IProgressMonitor monitor) throws CModelException { if (this.useCount == 0) - throw newNotPresentException(); // was destroyed + throw newNotPresentException(); // Was destroyed. - ReconcileWorkingCopyOperation op = new ReconcileWorkingCopyOperation(this, computeAST, forceProblemDetection); + ReconcileWorkingCopyOperation op = + new ReconcileWorkingCopyOperation(this, computeAST, forceProblemDetection); op.runOperation(monitor); return op.fAST; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java 2015-02-11 19:19:10.000000000 +0000 @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICQualifierType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType; @@ -58,11 +59,10 @@ import org.eclipse.core.runtime.Path; /** - * This is a utility class to help convert AST elements to Strings corresponding to + * Collection of static methods for converting AST elements to {@link String}s corresponding to * the AST element's type. - * + * * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. */ public class ASTTypeUtil { private static final String COMMA_SPACE = ", "; //$NON-NLS-1$ @@ -70,17 +70,19 @@ private static final String SPACE = " "; //$NON-NLS-1$ private static final int DEAULT_ITYPE_SIZE = 2; + private ASTTypeUtil() {} + /** - * Returns a string representation for the parameters of the given function type. + * Returns a string representation for the parameters of the given function type. * The representation contains the comma-separated list of the normalized parameter - * type representations wrapped in parentheses. + * type representations wrapped in parentheses. */ public static String getParameterTypeString(IFunctionType type) { StringBuilder result = new StringBuilder(); appendParameterTypeString(type, result); return result.toString(); } - + private static void appendParameterTypeString(IFunctionType ft, StringBuilder result) { IType[] types = ft.getParameterTypes(); result.append(Keywords.cpLPAREN); @@ -102,9 +104,8 @@ } /** - * @return Whether the function matching the given function binding takes - * parameters or not. - * + * Returns whether the function matching the given function binding takes parameters or not. + * * @since 5.1 */ public static boolean functionTakesParameters(IFunction function) { @@ -112,17 +113,16 @@ if (parameters.length == 0) { return false; - } + } if (parameters.length == 1 && SemanticUtil.isVoidType(parameters[0].getType())) { return false; } return true; } - + /** - * Returns a string representation for the type array. The representation is - * a comma-separated list of the normalized string representations of the - * provided types. + * Returns a string representation for the type array. The representation is a comma-separated + * list of the normalized string representations of the provided types. * @see #getTypeListString(IType[], boolean) */ public static String getTypeListString(IType[] types) { @@ -133,7 +133,8 @@ * Returns a String representation of the type array as a * comma-separated list. * @param types - * @return representation of the type array as a comma-separated list + * @param normalize indicates whether normalization shall be performed + * @return representation of the type array as a comma-separated list * @since 5.1 */ public static String getTypeListString(IType[] types, boolean normalize) { @@ -147,10 +148,10 @@ } return result.toString(); } - + /** * Returns a comma-separated list of the string representations of the arguments, enclosed - * in angle brackets. + * in angle brackets. * Optionally normalization is performed: *
template parameter names are represented by their parameter position, *
further normalization may be performed in future versions. @@ -164,20 +165,18 @@ } private static void appendArgumentList(ICPPTemplateArgument[] args, boolean normalize, StringBuilder result) { - boolean first= true; result.append('<'); - for (ICPPTemplateArgument arg : args) { - if (!first) { + for (int i = 0; i < args.length; i++) { + if (i != 0) { result.append(','); } - first= false; - appendArgument(arg, normalize, result); + appendArgument(args[i], normalize, result); } result.append('>'); } /** - * Returns a string representation for an template argument. Optionally + * Returns a string representation for an template argument. Optionally * normalization is performed: *
template parameter names are represented by their parameter position, *
further normalization may be performed in future versions. @@ -189,7 +188,7 @@ appendArgument(arg, normalize, buf); return buf.toString(); } - + private static void appendArgument(ICPPTemplateArgument arg, boolean normalize, StringBuilder buf) { IValue val= arg.getNonTypeValue(); if (val != null) { @@ -209,19 +208,19 @@ public static String[] getParameterTypeStringArray(IFunctionType type) { IType[] parms = type.getParameterTypes(); String[] result = new String[parms.length]; - + for (int i = 0; i < parms.length; i++) { if (parms[i] != null) { result[i] = getType(parms[i]); } } - + return result; } - + private static void appendTypeString(IType type, boolean normalize, StringBuilder result) { boolean needSpace = false; - + if (type instanceof IArrayType) { result.append(Keywords.cpLBRACKET); if (type instanceof ICArrayType) { @@ -247,7 +246,7 @@ } result.append(Keywords.VOLATILE); } - } + } IValue val= ((IArrayType) type).getSize(); if (val != null && val != Value.UNKNOWN) { if (normalize) { @@ -295,7 +294,7 @@ result.append(SPACE); needSpace = false; } result.append(Keywords.LONG_LONG); needSpace = true; - } + } if (basicType.isComplex()) { if (needSpace) { @@ -309,7 +308,7 @@ } result.append(Keywords.c_IMAGINARY); needSpace = true; } - + switch (kind) { case eChar: if (needSpace) result.append(SPACE); @@ -398,6 +397,9 @@ if (type instanceof ICPPFunctionType) { ICPPFunctionType ft= (ICPPFunctionType) type; needSpace= appendCVQ(result, needSpace, ft.isConst(), ft.isVolatile(), false); + if (ft.hasRefQualifier()) { + appendRefQualifier(result, needSpace, ft.isRValueReference()); needSpace = true; + } } } else if (type instanceof IPointerType) { if (type instanceof ICPPPointerToMemberType) { @@ -417,7 +419,7 @@ result.append(Keywords.RESTRICT); needSpace = true; } } - + IQualifierType qt= (IQualifierType) type; needSpace= appendCVQ(result, needSpace, qt.isConst(), qt.isVolatile(), false); } else if (type instanceof TypeOfDependentExpression) { @@ -425,7 +427,7 @@ } else if (type instanceof ISemanticProblem) { result.append('?'); } else if (type != null) { - result.append('@').append(type.hashCode()); + result.append('@').append(type.hashCode()); } } @@ -444,38 +446,46 @@ final boolean isVolatile, final boolean isRestrict) { if (isConst) { if (needSpace) { - target.append(SPACE); + target.append(SPACE); } - target.append(Keywords.CONST); + target.append(Keywords.CONST); needSpace = true; } if (isVolatile) { if (needSpace) { - target.append(SPACE); + target.append(SPACE); } - target.append(Keywords.VOLATILE); + target.append(Keywords.VOLATILE); needSpace = true; } if (isRestrict) { if (needSpace) { - target.append(SPACE); + target.append(SPACE); } - target.append(Keywords.RESTRICT); + target.append(Keywords.RESTRICT); needSpace = true; } return needSpace; } + private static void appendRefQualifier(StringBuilder target, boolean needSpace, + boolean isRValueReference) { + if (needSpace) { + target.append(SPACE); + } + target.append(isRValueReference ? Keywords.cpAND : Keywords.cpAMPER); + } + /** - * Returns the normalized string representation of the type. + * Returns the normalized string representation of the type. * @see #getType(IType, boolean) */ public static String getType(IType type) { return getType(type, true); } - + /** - * Returns a string representation of a type. + * Returns a string representation of a type. * Optionally the representation is normalized: *
typedefs are resolved *
template parameter names are represented by their parameter position @@ -489,67 +499,68 @@ appendType(type, normalize, result); return result.toString(); } - + /** * Appends the the result of {@link #getType(IType, boolean)} to the given buffer. * @since 5.3 */ public static void appendType(IType type, boolean normalize, StringBuilder result) { IType[] types = new IType[DEAULT_ITYPE_SIZE]; - - // Push all of the types onto the stack + int numTypes = 0; + + // Push all of the types onto the stack. int i = 0; IQualifierType cvq= null; ICPPReferenceType ref= null; while (type != null && ++i < 100) { if (type instanceof ITypedef) { - if (normalize) { - // Skip the typedef and proceed with its target type. - } else { + // If normalization was not requested, skip the typedef and proceed with its target + // type. + if (!normalize) { // Output reference, qualifier and typedef, then stop. if (ref != null) { - types = ArrayUtil.append(IType.class, types, ref); + types = ArrayUtil.appendAt(types, numTypes++, ref); ref= null; } if (cvq != null) { - types = ArrayUtil.append(IType.class, types, cvq); + types = ArrayUtil.appendAt(types, numTypes++, cvq); cvq= null; } - types = ArrayUtil.append(IType.class, types, type); - type= null; + types = ArrayUtil.appendAt(types, numTypes++, type); + type= null; } } else { if (type instanceof ICPPReferenceType) { - // Reference types ignore cv-qualifiers + // Reference types ignore cv-qualifiers. cvq= null; - // Lvalue references win over rvalue references + // Lvalue references win over rvalue references. if (ref == null || ref.isRValueReference()) { - // Delay reference to see if there are more + // Delay reference to see if there are more. ref= (ICPPReferenceType) type; } } else { if (cvq != null) { - // Merge cv qualifiers + // Merge cv qualifiers. if (type instanceof IQualifierType || type instanceof IPointerType) { type= SemanticUtil.addQualifiers(type, cvq.isConst(), cvq.isVolatile(), false); cvq= null; - } - } + } + } if (type instanceof IQualifierType) { // Delay cv qualifier to merge it with others cvq= (IQualifierType) type; } else { - // No reference, no cv qualifier: output reference and cv-qualifier + // No reference, no cv qualifier: output reference and cv-qualifier. if (ref != null) { - types = ArrayUtil.append(IType.class, types, ref); + types = ArrayUtil.appendAt(types, numTypes++, ref); ref= null; } if (cvq != null) { - types = ArrayUtil.append(IType.class, types, cvq); + types = ArrayUtil.appendAt(types, numTypes++, cvq); cvq= null; } - types = ArrayUtil.append(IType.class, types, type); - } + types = ArrayUtil.appendAt(types, numTypes++, type); + } } } if (type instanceof ITypeContainer) { @@ -559,53 +570,51 @@ } else { type= null; } - } - - // Pop all of the types off of the stack, and build the string representation while doing so. + } + + // Pop all of the types from the stack, and build the string representation while doing so. List postfix= null; BitSet parenthesis= null; boolean needParenthesis= false; boolean needSpace= false; - for (int j = types.length; --j >= 0;) { + for (int j = numTypes; --j >= 0;) { IType tj = types[j]; - if (tj != null) { - if (j > 0 && types[j - 1] instanceof IQualifierType) { - if (needSpace) - result.append(SPACE); - appendTypeString(types[j - 1], normalize, result); + if (j > 0 && types[j - 1] instanceof IQualifierType) { + if (needSpace) result.append(SPACE); - appendTypeString(tj, normalize, result); - needSpace= true; - --j; - } else { - // Handle post-fix - if (tj instanceof IFunctionType || tj instanceof IArrayType) { - if (j == 0) { - if (needSpace) - result.append(SPACE); - appendTypeString(tj, normalize, result); - needSpace= true; - } else { - if (postfix == null) { - postfix= new ArrayList<>(); - } - postfix.add(tj); - needParenthesis= true; - } - } else { + appendTypeString(types[j - 1], normalize, result); + result.append(SPACE); + appendTypeString(tj, normalize, result); + needSpace= true; + --j; + } else { + // Handle post-fix. + if (tj instanceof IFunctionType || tj instanceof IArrayType) { + if (j == 0) { if (needSpace) result.append(SPACE); - if (needParenthesis && postfix != null) { - result.append('('); - if (parenthesis == null) { - parenthesis= new BitSet(); - } - parenthesis.set(postfix.size() - 1); - } appendTypeString(tj, normalize, result); - needParenthesis= false; needSpace= true; + } else { + if (postfix == null) { + postfix= new ArrayList<>(); + } + postfix.add(tj); + needParenthesis= true; } + } else { + if (needSpace) + result.append(SPACE); + if (needParenthesis && postfix != null) { + result.append('('); + if (parenthesis == null) { + parenthesis= new BitSet(); + } + parenthesis.set(postfix.size() - 1); + } + appendTypeString(tj, normalize, result); + needParenthesis= false; + needSpace= true; } } } @@ -624,18 +633,18 @@ /** * For testing purposes, only. * Returns the normalized string representation of the type defined by the given declarator. - * + * * @noreference This method is not intended to be referenced by clients. */ public static String getType(IASTDeclarator declarator) { - // get the most nested declarator + // Get the most nested declarator. while (declarator.getNestedDeclarator() != null) { declarator = declarator.getNestedDeclarator(); } - + IBinding binding = declarator.getName().resolveBinding(); IType type = null; - + if (binding instanceof IEnumerator) { type = ((IEnumerator)binding).getType(); } else if (binding instanceof IFunction) { @@ -645,18 +654,18 @@ } else if (binding instanceof IVariable) { type = ((IVariable)binding).getType(); } - + if (type != null) { return getType(type); } - + return EMPTY_STRING; } /** * For testing purposes, only. - * Return's the String representation of a node's type (if available). - * + * Return's the String representation of a node's type (if available). + * * @noreference This method is not intended to be referenced by clients. */ public static String getNodeType(IASTNode node) { @@ -670,13 +679,13 @@ return getType((IType)((IASTName) node).resolveBinding()); if (node instanceof IASTTypeId) return getType((IASTTypeId) node); - + return EMPTY_STRING; } - + /** * Returns the type representation of the IASTTypeId as a String. - * + * * @param typeId * @return the type representation of the IASTTypeId as a String */ @@ -685,20 +694,20 @@ return createCType(typeId.getAbstractDeclarator()); else if (typeId instanceof CPPASTTypeId) return createCPPType(typeId.getAbstractDeclarator()); - + return EMPTY_STRING; } - + private static String createCType(IASTDeclarator declarator) { IType type = CVisitor.createType(declarator); return getType(type); } - + private static String createCPPType(IASTDeclarator declarator) { IType type = CPPVisitor.createType(declarator); return getType(type); } - + /** * @deprecated don't use it does something strange */ @@ -733,16 +742,16 @@ appendCppName(binding, false, true, buf); return buf.toString(); } - + private static void appendCppName(IBinding binding, boolean normalize, boolean qualify, StringBuilder result) { ICPPTemplateParameter tpar= getTemplateParameter(binding); if (tpar != null) { appendTemplateParameter(tpar, normalize, result); } else { if (qualify) { + int pos= result.length(); IBinding owner= binding.getOwner(); if (owner instanceof ICPPNamespace || owner instanceof IType) { - int pos= result.length(); appendCppName(owner, normalize, qualify, result); if (owner instanceof ICPPNamespace && owner.getNameCharArray().length == 0) { if (binding instanceof IIndexBinding) { @@ -767,24 +776,35 @@ } } } - if (result.length() > pos) - result.append("::"); //$NON-NLS-1$ + } else if (binding instanceof IType && owner instanceof ICPPFunction) { + try { + IScope scope = binding.getScope(); + if (scope != null) { + IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope); + if (node != null) + appendNodeLocation(node, true, result); + } + } catch (DOMException e) { + // Ignore. + } } + if (result.length() > pos) + result.append("::"); //$NON-NLS-1$ } appendNameCheckAnonymous(binding, result); } - + if (binding instanceof ICPPTemplateInstance) { appendArgumentList(((ICPPTemplateInstance) binding).getTemplateArguments(), normalize, result); } else if (binding instanceof ICPPUnknownMemberClassInstance) { appendArgumentList(((ICPPUnknownMemberClassInstance) binding).getArguments(), normalize, result); } } - + private static ICPPTemplateParameter getTemplateParameter(IBinding binding) { - if (binding instanceof ICPPTemplateParameter) + if (binding instanceof ICPPTemplateParameter) return (ICPPTemplateParameter) binding; - + if (binding instanceof ICPPDeferredClassInstance) return getTemplateParameter(((ICPPDeferredClassInstance) binding).getTemplateDefinition()); @@ -805,10 +825,10 @@ appendNameForAnonymous(binding, result); if (result.length() == 0) return null; - + return extractChars(result); } - + private static char[] extractChars(StringBuilder buf) { final int length = buf.length(); char[] result= new char[length]; @@ -824,24 +844,28 @@ node= ((ICPPInternalBinding) binding).getDefinition(); } if (node != null) { - IASTFileLocation loc= node.getFileLocation(); - if (loc == null) { - node= node.getParent(); - if (node != null) { - loc= node.getFileLocation(); - } - } - if (loc != null) { - char[] fname= loc.getFileName().toCharArray(); - int fnamestart= findFileNameStart(fname); - buf.append('{'); - buf.append(fname, fnamestart, fname.length - fnamestart); - if (!(binding instanceof ICPPNamespace)) { - buf.append(':'); - buf.append(loc.getNodeOffset()); - } - buf.append('}'); + appendNodeLocation(node, !(binding instanceof ICPPNamespace), buf); + } + } + + private static void appendNodeLocation(IASTNode node, boolean includeOffset, StringBuilder buf) { + IASTFileLocation loc= node.getFileLocation(); + if (loc == null) { + node= node.getParent(); + if (node != null) { + loc= node.getFileLocation(); + } + } + if (loc != null) { + char[] fname= loc.getFileName().toCharArray(); + int fnamestart= findFileNameStart(fname); + buf.append('{'); + buf.append(fname, fnamestart, fname.length - fnamestart); + if (includeOffset) { + buf.append(':'); + buf.append(loc.getNodeOffset()); } + buf.append('}'); } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICCompositeTypeScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICCompositeTypeScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICCompositeTypeScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICCompositeTypeScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -20,13 +20,13 @@ */ public interface ICCompositeTypeScope extends ICScope { /** - * get the binding for the member that has been previous added to this scope + * Returns the binding for the member that has been previous added to this scope * and that matches the given name. */ public IBinding getBinding(char[] name); /** - * Get the type this scope is associated with + * Returns the type this scope is associated with. * @since 4.0 */ public ICompositeType getCompositeType(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2012, 2014 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 @@ -16,6 +16,9 @@ /** * Represents an instance of an alias template (14.5.7). * @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 ICPPAliasTemplateInstance extends ITypedef, ICPPBinding { /** diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2012, 2014 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 @@ -16,6 +16,9 @@ /** * Represents an alias template (14.5.7). * @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 ICPPAliasTemplate extends IType, ICPPTemplateDefinition { /** diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTEnumerationSpecifier.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTEnumerationSpecifier.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTEnumerationSpecifier.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTEnumerationSpecifier.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -14,14 +14,13 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; /** - * enum struct : unsigned int {...} + * enum struct : unsigned int {...} * * @since 5.2 * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTEnumerationSpecifier extends IASTEnumerationSpecifier, ICPPASTDeclSpecifier { - public static final ASTNodeProperty BASE_TYPE = new ASTNodeProperty( "ICPPASTEnumerationSpecifier.BASE_TYPE [ICPPASTDeclSpecifier]"); //$NON-NLS-1$ @@ -35,18 +34,17 @@ public ICPPASTEnumerationSpecifier copy(CopyStyle style); /** - * Not allowed on frozen ast. + * Not allowed on frozen AST. */ public void setIsScoped(boolean isScoped); /** - * An enum is scoped if it uses the enumeration head - * enum class or enum struct + * An enum is scoped if it uses the enumeration head {@code enum class} or {@code enum struct}. */ public boolean isScoped(); /** - * Not allowed on frozen ast. + * Not allowed on frozen AST. */ public void setIsOpaque(boolean isOpaque); @@ -61,13 +59,13 @@ public void setBaseType(ICPPASTDeclSpecifier baseType); /** - * Returns the base type for this enum or null if it was not specified. + * Returns the base type for this enum or {@code null} if it was not specified. */ public ICPPASTDeclSpecifier getBaseType(); /** - * Returns the scope containing the enumerators of this enumeration, or null if the specifier - * is opaque. + * Returns the scope containing the enumerators of this enumeration, + * or {@code null} if the specifier is opaque. */ public ICPPScope getScope(); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -27,6 +27,11 @@ */ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator, ICPPASTDeclarator { /** + * @since 5.9 + */ + public enum RefQualifier { LVALUE, RVALUE } + + /** * Used as return value for {@link #getExceptionSpecification()}. * @since 5.1 */ @@ -100,6 +105,18 @@ public void setPureVirtual(boolean isPureVirtual); /** + * Returns the ref-qualifier. + * @since 5.9 + */ + public RefQualifier getRefQualifier(); + + /** + * Sets the ref-qualifier. + * @since 5.9 + */ + public void setRefQualifier(RefQualifier value); + + /** * @since 5.2 */ @Override diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLambdaExpression.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLambdaExpression.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLambdaExpression.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLambdaExpression.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -16,7 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner; /** - * Lambda expression, introduced in C++0x. + * Lambda expression, introduced in C++11. * * @since 5.3 * @noextend This interface is not intended to be extended by clients. @@ -64,8 +64,7 @@ * when creating AST for content assist. */ IASTCompoundStatement getBody(); - - + /** * Not allowed on frozen AST. * @see #getCaptureDefault() diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation + * John Camelon (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -20,74 +20,61 @@ * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTemplateDeclaration extends IASTDeclaration { + /** + * OWNED_DECLARATION is the subdeclaration that we maintain grammatically. + */ + public static final ASTNodeProperty OWNED_DECLARATION = new ASTNodeProperty( + "ICPPASTTemplateDeclaration.OWNED_DECLARATION - Subdeclaration maintained grammatically"); //$NON-NLS-1$ + + /** + * PARAMETER is used for template parameters. + */ + public static final ASTNodeProperty PARAMETER = new ASTNodeProperty( + "ICPPASTTemplateDeclaration.PARAMETER - Template Parameter"); //$NON-NLS-1$ /** * Is the export keyword used? - * - * @return boolean */ public boolean isExported(); /** * Should the export keyword be used? - * - * @param value - * boolean */ public void setExported(boolean value); /** - * OWNED_DECLARATION is the subdeclaration that we maintain - * grammatically. - */ - public static final ASTNodeProperty OWNED_DECLARATION = new ASTNodeProperty( - "ICPPASTTemplateDeclaration.OWNED_DECLARATION - Subdeclaration maintained grammatically"); //$NON-NLS-1$ - - /** - * Get template declaration. - * - * @return IASTDeclaration + * Returns the template declaration. */ public IASTDeclaration getDeclaration(); /** - * Set the template declaration. - * - * @param declaration - * IASTDeclaration + * Sets the template declaration. + * + * @param declaration the declaration to set */ public void setDeclaration(IASTDeclaration declaration); /** - * PARAMETER is used for template parameters. - */ - public static final ASTNodeProperty PARAMETER = new ASTNodeProperty( - "ICPPASTTemplateDeclaration.PARAMETER - Template Parameter"); //$NON-NLS-1$ - - /** - * Get template parameters. - * - * @return ICPPASTTemplateParameter[] + * Returns the template parameters. */ public ICPPASTTemplateParameter[] getTemplateParameters(); /** - * Add a template parameter. + * Adds a template parameter. * - * @param parm ICPPASTTemplateParameter + * @param paramm the parameter to add * @since 5.2 */ - public void addTemplateParameter(ICPPASTTemplateParameter parm); + public void addTemplateParameter(ICPPASTTemplateParameter paramm); /** * @deprecated Use addTemplateParameter. */ @Deprecated - public void addTemplateParamter(ICPPASTTemplateParameter parm); + public void addTemplateParamter(ICPPASTTemplateParameter paramm); /** - * get the template scope representing this declaration in the logical tree - * @return ICPPTemplateScope + * Returns the template scope representing this declaration in the logical tree. */ public ICPPTemplateScope getScope(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -22,7 +22,7 @@ * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface ICPPClassSpecialization extends ICPPSpecialization, ICPPClassType { +public interface ICPPClassSpecialization extends ICPPTypeSpecialization, ICPPClassType { @Override ICPPClassType getSpecializedBinding(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecializationSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecializationSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecializationSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecializationSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -17,7 +17,6 @@ * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface ICPPClassTemplatePartialSpecializationSpecialization extends - ICPPClassTemplatePartialSpecialization, ICPPClassSpecialization { - +public interface ICPPClassTemplatePartialSpecializationSpecialization + extends ICPPClassTemplatePartialSpecialization, ICPPClassSpecialization { } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumerationSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumerationSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumerationSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumerationSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -15,7 +15,7 @@ /** * @since 5.5 */ -public interface ICPPEnumerationSpecialization extends ICPPEnumeration, ICPPSpecialization { +public interface ICPPEnumerationSpecialization extends ICPPEnumeration, ICPPTypeSpecialization { @Override ICPPEnumeration getSpecializedBinding(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionType.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005-2009 IBM Corporation and others. + * Copyright (c) 2005, 2014 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 @@ -21,21 +21,33 @@ */ public interface ICPPFunctionType extends IFunctionType { /** - * Returns true for a constant method + * Returns {@code true} for a constant method. */ public boolean isConst(); - + /** - * Returns true for a volatile method + * Returns {@code true} for a volatile method. */ public boolean isVolatile(); - + + /** + * Returns {@code true} for a method declared with a ref-qualifier. + * @since 5.9 + */ + public boolean hasRefQualifier(); + + /** + * Returns {@code true} if the type of the implicit object parameter is an rvalue reference. + * @since 5.9 + */ + public boolean isRValueReference(); + /** * Whether the function type takes variable number of arguments. * @since 5.2 */ public boolean takesVarArgs(); - + /** * @deprecated function types don't relate to this pointers at all. * @noreference This method is not intended to be referenced by clients and should be removed. diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java 2015-02-11 19:19:10.000000000 +0000 @@ -279,6 +279,18 @@ public ICPPASTQualifiedName newQualifiedName(); /** + * @since 5.9 + */ + @Override + public ICPPASTName newName(); + + /** + * @since 5.9 + */ + @Override + public ICPPASTName newName(char[] name); + + /** * Creates a range based for statement. * @since 5.3 */ diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java 2015-02-11 19:19:10.000000000 +0000 @@ -31,7 +31,7 @@ ICPPTemplateInstance[] EMPTY_TEMPLATE_INSTANCE_ARRAY = {}; /** - * get the template that this was instantiated from + * Returns the template that this instance was instantiated from. */ public ICPPTemplateDefinition getTemplateDefinition(); @@ -43,7 +43,7 @@ /** * Explicit specializations are modeled as instances of a template. - * Returns true if this binding is an explicit specialization. + * Returns {@code true} if this binding is an explicit specialization. * @since 5.2 */ public boolean isExplicitSpecialization(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTypeSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTypeSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTypeSpecialization.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTypeSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2014 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.core.dom.ast.cpp; + +import org.eclipse.cdt.core.dom.ast.IType; + +/** + * A common interface for ICPPClassSpecialization and ICPPEnumerationSpecialization. + * + * @since 5.9 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICPPTypeSpecialization extends ICPPSpecialization, IType { +} diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -8,6 +8,7 @@ * Contributors: * Andrew Niefer (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -17,19 +18,26 @@ */ public interface IArrayType extends IType { /** - * get the type that this is an array of + * Returns the type that this is an array of. */ IType getType(); /** - * Returns the value for the size of the array type, or null if it is unspecified. + * Returns the value for the size of the array type, or {@code null} if it is unspecified. * @since 5.2 */ IValue getSize(); - + + /** + * Checks is the array type has specified size. + * @since 5.9 + */ + boolean hasSize(); + /** - * get the expression that represents the size of this array + * Returns the expression that represents the size of this array * @throws DOMException */ + @Deprecated IASTExpression getArraySizeExpression() throws DOMException; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java 2015-02-11 19:19:10.000000000 +0000 @@ -20,23 +20,29 @@ /** * This interface represents an enumerator member of an enum specifier. * - * @author jcamelon * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTEnumerator extends IASTNode, IASTNameOwner { /** * Empty array (constant). */ - public static final IASTEnumerator[] EMPTY_ENUMERATOR_ARRAY = new IASTEnumerator[0]; + public static final IASTEnumerator[] EMPTY_ENUMERATOR_ARRAY = {}; /** - * ENUMERATOR_NAME describes the relationship between - * IASTEnumerator and IASTName. + * {@code ENUMERATOR_NAME} describes the relationship between + * {@code IASTEnumerator} and {@code IASTName}. */ public static final ASTNodeProperty ENUMERATOR_NAME = new ASTNodeProperty( "IASTEnumerator.ENUMERATOR_NAME - IASTName for IASTEnumerator"); //$NON-NLS-1$ /** + * {@code ENUMERATOR_VALUE} describes the relationship between + * {@code IASTEnumerator} and {@code IASTExpression}. + */ + public static final ASTNodeProperty ENUMERATOR_VALUE = new ASTNodeProperty( + "IASTEnumerator.ENUMERATOR_VALUE - IASTExpression (value) for IASTEnumerator"); //$NON-NLS-1$ + + /** * Set the enumerator's name. * * @param name @@ -46,18 +52,11 @@ /** * Get the enumerator's name. * - * @return IASTName + * @return {@code IASTName} */ public IASTName getName(); /** - * ENUMERATOR_VALUE describes the relationship between - * IASTEnumerator and IASTExpression. - */ - public static final ASTNodeProperty ENUMERATOR_VALUE = new ASTNodeProperty( - "IASTEnumerator.ENUMERATOR_VALUE - IASTExpression (value) for IASTEnumerator"); //$NON-NLS-1$ - - /** * Sets enumerator value. * * @param expression @@ -67,7 +66,7 @@ /** * Returns enumerator value. * - * @return IASTExpression value + * @return {@code IASTExpression} value */ public IASTExpression getValue(); @@ -82,13 +81,19 @@ */ @Override public IASTEnumerator copy(CopyStyle style); - } /** - * ENUMERATOR describes the relationship between - * IASTEnumerationSpecifier and the nested - * IASTEnumerators. + * {@code ENUMERATION_NAME} describes the relationship between + * {@code IASTEnumerationSpecifier} and its {@link IASTName}. + */ + public static final ASTNodeProperty ENUMERATION_NAME = new ASTNodeProperty( + "IASTEnumerationSpecifier.ENUMERATION_NAME - IASTName for IASTEnumerationSpecifier"); //$NON-NLS-1$ + + /** + * {@code ENUMERATOR} describes the relationship between + * {@code IASTEnumerationSpecifier} and the nested + * {@link IASTEnumerator}s. */ public static final ASTNodeProperty ENUMERATOR = new ASTNodeProperty( "IASTEnumerationSpecifier.ENUMERATOR - nested IASTEnumerator for IASTEnumerationSpecifier"); //$NON-NLS-1$ @@ -96,26 +101,18 @@ /** * Adds an enumerator. * - * @param enumerator - * IASTEnumerator + * @param enumerator {@code IASTEnumerator} */ public void addEnumerator(IASTEnumerator enumerator); /** * Returns enumerators. * - * @return IASTEnumerator [] array + * @return {@code IASTEnumerator[]} array */ public IASTEnumerator[] getEnumerators(); /** - * ENUMERATION_NAME describes the relationship between - * IASTEnumerationSpecifier and its IASTName. - */ - public static final ASTNodeProperty ENUMERATION_NAME = new ASTNodeProperty( - "IASTEnumerationSpecifier.ENUMERATION_NAME - IASTName for IASTEnumerationSpecifier"); //$NON-NLS-1$ - - /** * Sets the enum's name. * * @param name @@ -123,7 +120,7 @@ public void setName(IASTName name); /** - * Get the enum's name. + * Returns the enum's name. */ public IASTName getName(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java 2015-02-11 19:19:10.000000000 +0000 @@ -19,22 +19,22 @@ */ public interface IASTLiteralExpression extends IASTExpression { /** - * An integer literal e.g. 5 + * An integer literal e.g. {@code 5} */ public static final int lk_integer_constant = 0; /** - * A floating point literal e.g. 6.0 + * A floating point literal e.g. {@code 6.0} */ public static final int lk_float_constant = 1; /** - * A char literal e.g. 'a' + * A character literal e.g. {@code 'a'} */ public static final int lk_char_constant = 2; /** - * A string literal e.g. "a literal" + * A string literal e.g. {@code "a literal"} */ public static final int lk_string_literal = 3; @@ -46,31 +46,32 @@ public static final int lk_last = lk_string_literal; /** - * lk_this represents the 'this' keyword for c++ only. + * {@code lk_this} represents the '{@code this}' keyword for C++ only. * @since 5.1 */ public static final int lk_this = 4; /** - * lk_true represents the 'true' keyword. + * {@code lk_true} represents the '{@code true}' keyword. * @since 5.1 */ public static final int lk_true = 5; /** - * lk_false represents the 'false' keyword. + * {@code lk_false} represents the '{@code false}' keyword. * @since 5.1 */ public static final int lk_false = 6; /** - * lk_nullptr represents the 'nullptr' keyword. + * {@code lk_nullptr} represents the '{@code nullptr}' keyword. * @since 5.4 */ public static final int lk_nullptr = 7; /** - * Get the literal expression kind. + * Returns the kind of the literal expression kind, which can be one of the {@code lk_*} + * constants defined above. */ public int getKind(); @@ -88,12 +89,12 @@ public String toString(); /** - * Set the literal expression kind. + * Sets the kind of the literal expression. */ public void setKind(int value); /** - * Provide the value for the expression. + * Sets the value for the expression. * @since 5.1 */ public void setValue(char[] value); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java 2015-02-11 19:19:10.000000000 +0000 @@ -38,71 +38,69 @@ */ withLocations } - + public static final IASTNode[] EMPTY_NODE_ARRAY = {}; - + /** - * Get the translation unit (master) node that is the ancestor of all nodes + * Returns the translation unit (master) node that is the ancestor of all nodes * in this AST. - * - * @return IASTTranslationUnit + * + * @return {@code IASTTranslationUnit} */ public IASTTranslationUnit getTranslationUnit(); /** - * Get the location of this node. In cases not involving macro expansions, + * Returns the location of this node. In cases not involving macro expansions, * the IASTNodeLocation[] result will only have one element in it, and it - * will be an IASTFileLocation. - * + * will be an {@link IASTFileLocation}. + *

* Where the node is completely generated within a macro expansion, * IASTNodeLocation[] result will have one element in it, and it will be an * {@link IASTMacroExpansionLocation}. - * + *

* Nodes that span file context into a macro expansion (and potentially out * of the macro expansion again) result in an IASTNodeLocation[] result * that is of length > 1. - * + *

* We do not provide meaningful node locations for nested macro references * (see {@link IASTPreprocessorMacroExpansion#getNestedMacroReferences()}). - * For those, the file location of the enclosing explicit macro reference is + * For those, the file location of the enclosing explicit macro reference is * returned. You can however compute their image-location using * {@link IASTName#getImageLocation()} */ public IASTNodeLocation[] getNodeLocations(); - + /** * Computes a file location for the node. When the node actually resides in a macro-expansion * the location of the expansion is returned. In case the node spans multiple files the location * will be in a common root file and will contain the appropriate include directives. *

- * The method may return null in case the node does not have a file-location. This + * The method may return {@code null} in case the node does not have a file-location. This * is for instance the case for built-in macro names or empty names for anonymous type * declarations. - * - * @return the mapped file location or null. + * + * @return the mapped file location or {@code null}. */ public IASTFileLocation getFileLocation(); - + /** - * Lightweight check for understanding what file we are in. - * - * @return String absolute path + * Lightweight check for understanding what file we are in. + * + * @return {@code String} absolute path */ public String getContainingFilename(); - + /** - * Lightweight check to see whether this node is part of the root file. - * @since 5.0 + * Lightweight check to see whether this node is part of the root file. + * @since 5.0 */ public boolean isPartOfTranslationUnitFile(); - + /** - * Get the parent node of this node in the tree. - * - * @return the parent node of this node + * Returns the parent node of this node in the tree. */ public IASTNode getParent(); - + /** * Returns the children of this node. * @since 5.1 @@ -110,43 +108,44 @@ IASTNode[] getChildren(); /** - * Set the parent node of this node in the tree. - * - * @param node - * IASTNode + * Sets the parent node of this node in the tree. + * + * @param node {@code IASTNode} */ public void setParent(IASTNode node); /** - * In order to properly understand the relationship between this child node - * and it's parent, a node property object is used. - * - * @return ASTNodeProperty + * Describes relationship between this child node and it's parent. + * + * @return {@code ASTNodeProperty} */ public ASTNodeProperty getPropertyInParent(); /** - * Set the parent property of the node. - * + * Sets the parent property of the node. + * * @param property */ public void setPropertyInParent(ASTNodeProperty property); /** * Abstract method to be overridden by all subclasses. Necessary for - * visitation of the tree using an ASTVisitor. - * + * visitation of the tree using an {@code ASTVisitor}. + * * @param visitor - * @return continue on (true) or quit( false ) + * @return continue on (true) or quit (false) */ public boolean accept(ASTVisitor visitor); - + /** * Returns the raw signature of the IASTNode before it is processed by the preprocessor. - * + * * Example: + *

      * #define ONE 1
      * int x=ONE; // getRawSignature() for this declaration would return "int x=ONE;"
+     * 
+ * * @return the raw signature of the IASTNode before it is processed by the preprocessor */ public String getRawSignature(); @@ -154,23 +153,25 @@ /** * Returns whether this node contains the given one. The decision is made * purely on location information and therefore the method is fast. + * * @param node the node to check * @return whether this node contains the given one. * @since 4.0 */ public boolean contains(IASTNode node); - + /** * Returns the tokens that can be found between this node and its left sibling (or the - * beginning of the parent, if there is no left sibling). The tokens are obtained + * beginning of the parent, if there is no left sibling). The tokens are obtained * from the lexer, no preprocessing is performed. * The offsets of the tokens are relative to the file-offset of this node. - *

Examples looking at the condition of if-statements: + *

+ * Examples looking at the condition of if-statements: *

 	 * #define IF      if
      * #define IF_P    if (
      * #define IF_P_T  if (true
-     * #define SEMI_IF ; if 
+     * #define SEMI_IF ; if
      * #define IF_COND if (true)
      * void test() {
      *    if (true) {}       // leading syntax: 'if ('
@@ -180,11 +181,12 @@
      *    SEMI_IF (true) {}  // throws ExpansionOverlapsBoundaryException
      *    IF_COND            // throws ExpansionOverlapsBoundaryException
      * 
- * @return a chain of tokens or null, if there are none. + * + * @return a chain of tokens or {@code null}, if there are none. * @throws ExpansionOverlapsBoundaryException if one of the boundaries of the leading syntax is - * overlapped by a macro-expansion. + * overlapped by a macro-expansion. * @throws UnsupportedOperationException if invoked on preprocessor nodes, or nodes that are not - * part of a translation unit. + * part of a translation unit. * @since 5.1 */ public IToken getLeadingSyntax() throws ExpansionOverlapsBoundaryException, @@ -195,22 +197,26 @@ * end of the parent, if there is no right sibling). The tokens are obtained from the lexer, * no preprocessing is performed. * The offsets of the tokens are relative to the file-offset of the end of this node. - *

For examples see {@link #getLeadingSyntax()}. - * @return a chain of tokens or null, if there are none. + *

+ * For examples see {@link #getLeadingSyntax()}. + * + * @return a chain of tokens or {@code null}, if there are none. * @throws ExpansionOverlapsBoundaryException if one of the boundaries of the trailing syntax is - * overlapped by a macro-expansion. + * overlapped by a macro-expansion. * @throws UnsupportedOperationException if invoked on preprocessor nodes, or nodes that are not - * part of a translation unit. + * part of a translation unit. * @since 5.1 */ public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException, UnsupportedOperationException; - + /** * Returns the tokens that make up this node. The tokens are obtained from the lexer, * no preprocessing is performed. * The offsets of the tokens are relative to the file-offset of the beginning of this node. - *

For examples see {@link #getLeadingSyntax()}. - * @return a chain of tokens or null, if there are none. + *

+ * For examples see {@link #getLeadingSyntax()}. + * + * @return a chain of tokens or {@code null}, if there are none. * @throws ExpansionOverlapsBoundaryException if one of the boundaries of the node is * overlapped by a macro-expansion. * @throws UnsupportedOperationException if invoked on preprocessor nodes, or nodes that are not @@ -218,7 +224,7 @@ * @since 5.1 */ public IToken getSyntax() throws ExpansionOverlapsBoundaryException; - + /** * Returns true if this node is frozen, false otherwise. * If the node is frozen then any attempt to call a method that changes @@ -226,28 +232,27 @@ * @since 5.1 */ public boolean isFrozen(); - + /** * Returns false if this node was parsed in an inactive code branch. * @since 5.1 */ public boolean isActive(); - + /** * Returns a mutable copy of the tree rooted at this node. The following postconditions hold: - * - * + *

 	 * copy.getParent() == null
 	 * copy.getPropertyInParent() == null
 	 * copy.isFrozen() == false
-	 * 
-	 * 
+	 * 
+ * * Preprocessor nodes do not currently support being copied. - * + * * Implicit name nodes are not copied, instead they can be regenerated if required. - * - * Calling this method is equivalent - * + *

+ * Calling this method is equivalent to {@code copy(CopyStyle.withoutLocations)}. + * * @since 5.1 * @throws UnsupportedOperationException * if this node or one of its descendants does not support copying @@ -256,17 +261,17 @@ /** * Returns a mutable copy of the tree rooted at this node. The following postconditions hold: - * - * + * + *

 	 * copy.getParent() == null
 	 * copy.getPropertyInParent() == null
 	 * copy.isFrozen() == false
-	 * 
-	 * 
+	 * 
+ * * Preprocessor nodes do not currently support being copied. - * + * * Implicit name nodes are not copied, instead they can be regenerated if required. - * + * * @param style * {@link CopyStyle} create a copy with or without locations. Please see * {@link CopyStyle} for restrictions on copies with Locations. diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java 2015-02-11 19:19:10.000000000 +0000 @@ -54,7 +54,7 @@ public IField findField(String name); /** - * Returns the IScope object that is associated with this composite type + * Returns the IScope object that is associated with this composite type. */ public IScope getCompositeScope(); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumeration.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumeration.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumeration.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumeration.java 2015-02-11 19:19:10.000000000 +0000 @@ -25,6 +25,7 @@ * @since 5.2 */ long getMinValue(); + /** * @since 5.2 */ diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumerator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumerator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumerator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IEnumerator.java 2015-02-11 19:19:10.000000000 +0000 @@ -20,11 +20,11 @@ /** * Returns the type of this enumeration. The type of an enumerator * is the enumeration in which it is declared. - * + * * @return the type of the enumeration */ public IType getType(); - + /** * Returns the value assigned to this enumerator. * @since 5.1 diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -137,40 +137,40 @@ } } - public void setPrefixLookup(boolean prefixLookup) { + public final void setPrefixLookup(boolean prefixLookup) { fPrefixLookup = prefixLookup; } - public void setResolve(boolean resolve) { + public final void setResolve(boolean resolve) { fResolve = resolve; } - public void setIgnorePointOfDeclaration(boolean ignorePointOfDeclaration) { + public final void setIgnorePointOfDeclaration(boolean ignorePointOfDeclaration) { fIgnorePointOfDeclaration = ignorePointOfDeclaration; } - public void setLookupKey(char[] key) { + public final void setLookupKey(char[] key) { fLookupKey= key; } - public char[] getLookupKey() { + public final char[] getLookupKey() { return fLookupKey; } - public IASTNode getLookupPoint() { + public final IASTNode getLookupPoint() { return fLookupPoint; } - public boolean isResolve() { + public final boolean isResolve() { return fResolve; } - public boolean isPrefixLookup() { + public final boolean isPrefixLookup() { return fPrefixLookup; } - public boolean isIgnorePointOfDeclaration() { + public final boolean isIgnorePointOfDeclaration() { return fIgnorePointOfDeclaration; } - public IIndexFileSet getIncludedFiles() { + public final IIndexFileSet getIncludedFiles() { return fTu == null ? IIndexFileSet.EMPTY : fTu.getIndexFileSet(); } - public IIndex getIndex() { + public final IIndex getIndex() { return fTu == null ? null : fTu.getIndex(); } - public IASTName getLookupName() { + public final IASTName getLookupName() { return fLookupPointIsName ? (IASTName) fLookupPoint : null; } public IASTTranslationUnit getTranslationUnit() { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java 2015-02-11 19:19:10.000000000 +0000 @@ -131,8 +131,8 @@ public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory codeReaderFactory, IIndex index, int options, IParserLogService log) throws CoreException { - return getASTTranslationUnit(FileContent.adapt(reader), scanInfo, IncludeFileContentProvider - .adapt(codeReaderFactory), index, options, log); + return getASTTranslationUnit(FileContent.adapt(reader), scanInfo, + IncludeFileContentProvider.adapt(codeReaderFactory), index, options, log); } @Override @@ -167,7 +167,7 @@ IASTTranslationUnit ast= parser.parse(); ast.setIsHeaderUnit((options & OPTION_IS_SOURCE_UNIT) == 0); return ast; - } catch(ParseError e) { + } catch (ParseError e) { // Only the TOO_MANY_TOKENS error can be handled here. if (e.getErrorKind() != ParseErrorKind.TOO_MANY_TOKENS) throw e; @@ -178,7 +178,7 @@ if (scanner.getLocationResolver() != null) tuName = scanner.getLocationResolver().getTranslationUnitPath(); - log.traceLog(e.getMessage() + (tuName == null ? new String() : (" while parsing " + tuName))); //$NON-NLS-1$ + log.traceLog(e.getMessage() + (tuName == null ? "" : (" while parsing " + tuName))); //$NON-NLS-1$ //$NON-NLS-2$ } return null; } finally { @@ -241,7 +241,8 @@ * @return an instance of ISourceCodeParser * @since 5.6 */ - protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options, IParserSettings settings) { + protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, + boolean forCompletion, int options, IParserSettings settings) { ParserMode mode = createParserMode(forCompletion, options); return createParser(scanner, mode, log, index, options, settings); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPParserExtensionConfiguration.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPParserExtensionConfiguration.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPParserExtensionConfiguration.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPParserExtensionConfiguration.java 2015-02-11 19:19:10.000000000 +0000 @@ -11,117 +11,80 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.parser.cpp; +import java.util.Collections; +import java.util.Map; + import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider; +import org.eclipse.cdt.core.parser.IToken.ContextSensitiveTokenType; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider; - /** * Abstract C++ parser extension configuration to help model C++ dialects. * * @since 4.0 */ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPParserExtensionConfiguration { - - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#allowRestrictPointerOperators() - */ @Override public boolean allowRestrictPointerOperators() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportAlignOfUnaryExpression() - */ @Override public boolean supportAlignOfUnaryExpression() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportAttributeSpecifiers() - */ @Override public boolean supportAttributeSpecifiers() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportComplexNumbers() - */ @Override public boolean supportComplexNumbers() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers() - */ @Override public boolean supportDeclspecSpecifiers() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportExtendedTemplateSyntax() - */ @Override public boolean supportExtendedTemplateSyntax() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportGCCOtherBuiltinSymbols() - */ @Override public boolean supportGCCOtherBuiltinSymbols() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportKnRC() - */ @Override public boolean supportKnRC() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportLongLongs() - */ @Override public boolean supportLongLongs() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportMinAndMaxOperators() - */ @Override public boolean supportMinAndMaxOperators() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportRestrictKeyword() - */ @Override public boolean supportRestrictKeyword() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportStatementsInExpressions() - */ @Override public boolean supportStatementsInExpressions() { return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportTypeofUnaryExpressions() - */ @Override public boolean supportTypeofUnaryExpressions() { return false; @@ -154,11 +117,16 @@ return false; } - /* - * @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#getBuiltinBindingsProvider() - */ @Override public IBuiltinBindingsProvider getBuiltinBindingsProvider() { return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, supportGCCOtherBuiltinSymbols()); } + + /** + * @since 5.9 + */ + @Override + public Map getAdditionalContextSensitiveKeywords() { + return Collections.emptyMap(); + } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPParserExtensionConfiguration.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPParserExtensionConfiguration.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPParserExtensionConfiguration.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPParserExtensionConfiguration.java 2015-02-11 19:19:10.000000000 +0000 @@ -12,8 +12,13 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.parser.cpp; +import java.util.HashMap; +import java.util.Map; + import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider; +import org.eclipse.cdt.core.parser.GCCKeywords; import org.eclipse.cdt.core.parser.ParserLanguage; +import org.eclipse.cdt.core.parser.IToken.ContextSensitiveTokenType; import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider; /** @@ -131,4 +136,12 @@ public IBuiltinBindingsProvider getBuiltinBindingsProvider() { return new GCCBuiltinSymbolProvider(ParserLanguage.CPP, true); } + + @Override + public Map getAdditionalContextSensitiveKeywords() { + Map result = + new HashMap<>(super.getAdditionalContextSensitiveKeywords()); + result.put(GCCKeywords.__FINAL, ContextSensitiveTokenType.FINAL); + return result; + } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java 2015-02-11 19:19:10.000000000 +0000 @@ -13,8 +13,11 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.parser.cpp; +import java.util.Map; + import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider; import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; +import org.eclipse.cdt.core.parser.IToken.ContextSensitiveTokenType; /** * C++ parser extension configuration interface. @@ -147,6 +150,12 @@ public boolean supportFunctionStyleAssembler(); /** + * Additional variants of context-sensitive keywords. + * @since 5.9 + */ + public Map getAdditionalContextSensitiveKeywords(); + + /** * @deprecated use {@link #getBuiltinBindingsProvider()} instead. */ @Deprecated diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java 2015-02-11 19:19:10.000000000 +0000 @@ -24,18 +24,13 @@ */ public interface IIndexFileLocation { /** - * The URI of the indexed file. - * - * @return the URI of the indexed file (non-{@code null}) + * Returns the URI of the indexed file (non-{@code null}). */ public URI getURI(); /** - * Returns the workspace relative path of the indexed file or {@code null} if the file + * Returns the workspace relative path of the file in the index or {@code null} if the file * is not in the workspace. - * - * @return the workspace relative path of the file in the index, or null if the - * file is not in the workspace */ public String getFullPath(); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java 2015-02-11 19:19:10.000000000 +0000 @@ -29,6 +29,8 @@ public static final String __INT128 = "__int128"; /** @since 5.5 */ public static final String __FLOAT128 = "__float128"; + /** @since 5.9 */ + public static final String __FINAL = "__final"; public static final char[] cpTYPEOF = TYPEOF.toCharArray(), @@ -84,4 +86,8 @@ public static final char[] cp__is_final= "__is_final".toCharArray(), cp__underlying_type= "__underlying_type".toCharArray(); + + /** @since 5.9 */ + public static final char[] + cp__FINAL= __FINAL.toCharArray(); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2010 IBM Corporation and others. + * Copyright (c) 2002, 2015 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 @@ -8,6 +8,7 @@ * Contributors: * John Camelon (IBM Rational Software) - Initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.parser; @@ -95,6 +96,8 @@ */ int tGT_in_SHIFTR= 5201; + /** @since 5.9 */ int t_alignas = 5900; + /** @since 5.9 */ int t_alignof = 5901; /** @deprecated use {@link #tAND} */ @Deprecated int t_and = 54; /** @deprecated use {@link #tAMPERASSIGN} */ @Deprecated int t_and_eq = 55; int t_asm = 56; @@ -106,10 +109,8 @@ int t_case = 62; int t_catch = 63; int t_char = 64; - /** @since 5.2 */ - int t_char16_t= 5202; - /** @since 5.2 */ - int t_char32_t= 5203; + /** @since 5.2 */ int t_char16_t= 5202; + /** @since 5.2 */ int t_char32_t= 5203; int t_class = 65; /** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int tCOMPL= tBITCOMPLEMENT; /** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int t_compl = 66; @@ -118,8 +119,7 @@ /** @since 5.4 */ int t_constexpr = 5400; int t_const_cast = 69; int t_continue = 70; - /** @since 5.2 */ - int t_decltype= 5204; + /** @since 5.2 */ int t_decltype= 5204; int t_default = 71; int t_delete = 72; int t_do = 73; @@ -158,8 +158,7 @@ int t_short = 104; int t_sizeof = 105; int t_static = 106; - /** @since 5.2 */ - int t_static_assert = 5205; + /** @since 5.2 */ int t_static_assert = 5205; int t_static_cast = 107; int t_signed = 108; int t_struct = 109; @@ -216,7 +215,15 @@ int FIRST_RESERVED_IExtensionToken = 243; int LAST_RESERVED_IExtensionToken = 299; - + + /** + * Token types for context-sensitive tokens. + * @since 5.9 + */ + enum ContextSensitiveTokenType { + OVERRIDE, + FINAL + } /** * @noreference This method is not intended to be referenced by clients. diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2012 IBM Corporation and others. + * Copyright (c) 2002, 2015 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 @@ -9,6 +9,7 @@ * John Camelon (IBM Rational Software) - Initial API and implementation * Anton Leherbauer (Wind River Systems) * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.core.parser; @@ -65,6 +66,8 @@ public static final String EXPORT = "export"; public static final String EXTERN = "extern"; public static final String FALSE = "false"; + /** @since 5.9 */ + public static final String FINAL = "final"; public static final String FLOAT = "float"; public static final String FOR = "for"; public static final String FRIEND = "friend"; @@ -86,6 +89,8 @@ public static final String OPERATOR = "operator"; public static final String OR = "or"; public static final String OR_EQ = "or_eq"; + /** @since 5.9 */ + public static final String OVERRIDE = "override"; public static final String PRIVATE = "private"; public static final String PROTECTED = "protected"; public static final String PUBLIC = "public"; @@ -169,7 +174,7 @@ public static final char[] cFLOAT = "float".toCharArray(); public static final char[] cFOR = "for".toCharArray(); /** @since 5.5 */ - public static final char[] cFINAL = "final".toCharArray(); + public static final char[] cFINAL = FINAL.toCharArray(); public static final char[] cFRIEND = "friend".toCharArray(); public static final char[] cGOTO = "goto".toCharArray(); public static final char[] cIF = "if".toCharArray(); @@ -189,7 +194,7 @@ public static final char[] cOR = "or".toCharArray(); public static final char[] cOR_EQ = "or_eq".toCharArray(); /** @since 5.5 */ - public static final char[] cOVERRIDE = "override".toCharArray(); + public static final char[] cOVERRIDE = OVERRIDE.toCharArray(); public static final char[] cPRIVATE = "private".toCharArray(); public static final char[] cPROTECTED = "protected".toCharArray(); public static final char[] cPUBLIC = "public".toCharArray(); @@ -302,7 +307,7 @@ public static final char[] cVA_ARGS= "__VA_ARGS__".toCharArray(); - // preprocessor extensions (supported by GCC) + // Preprocessor extensions (supported by GCC). public static final char[] cINCLUDE_NEXT = "include_next".toCharArray(); public static final char[] cIMPORT = "import".toCharArray(); public static final char[] cIDENT = "ident".toCharArray(); @@ -323,6 +328,8 @@ private static void addCommon(CharArrayIntMap words) { words.put(Keywords._Pragma, IToken.t_PRAGMA); + words.put(Keywords.cALIGNAS, IToken.t_alignas); + words.put(Keywords.cALIGNOF, IToken.t_alignof); words.put(Keywords.cAUTO, IToken.t_auto); words.put(Keywords.cBREAK, IToken.t_break); words.put(Keywords.cCASE, IToken.t_case); @@ -359,7 +366,7 @@ words.put(Keywords.cASM, IToken.t_asm); } - // ANSI C keywords + // ANSI C keywords private static void addC(CharArrayIntMap ckeywords) { ckeywords.put(Keywords.cRESTRICT, IToken.t_restrict); ckeywords.put(Keywords.c_BOOL, IToken.t__Bool); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -345,7 +345,8 @@ } /** - * Adds all elements of an array to a collection. + * Adds all elements of an array to a collection. For an {@link ArrayList} this method is + * slightly more efficient than {@link java.util.Collections#addAll(Collection, T...)}. * @since 5.4 */ @SafeVarargs diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2014 Wind River Systems, 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 @@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; @@ -196,7 +195,7 @@ return unsignedType; } - // the signed has the higher rank + // The signed has the higher rank. if (signedRank.ordinal() > unsignedRank.ordinal()) { return signedType; } @@ -227,7 +226,7 @@ return createBasicType(Kind.eInt, domain.getModifier()); case eChar32: - // Assuming 32 bits + // Assuming 32 bits. return createBasicType(Kind.eInt, domain.getModifier() | IBasicType.IS_UNSIGNED); case eInt: @@ -332,7 +331,7 @@ } } - public static boolean fitsIntoType(ICPPBasicType basicTarget, long n) { + public static boolean fitsIntoType(IBasicType basicTarget, long n) { final Kind kind = basicTarget.getKind(); switch (kind) { case eInt: @@ -340,7 +339,7 @@ if (basicTarget.isShort()) { return Short.MIN_VALUE <= n && n <= Short.MAX_VALUE; } - // Can't represent long longs with java longs. + // Can't represent long longs with Java longs. if (basicTarget.isLong() || basicTarget.isLongLong()) { return true; } @@ -352,7 +351,7 @@ if (basicTarget.isShort()) { return n < (Short.MAX_VALUE + 1L) * 2; } - // Can't represent long longs with java longs. + // Can't represent long longs with Java longs. if (basicTarget.isLong() || basicTarget.isLongLong()) { return true; } @@ -372,9 +371,9 @@ } /** - * Make a best-effort guess at the sizeof() of an integral type. + * Makes a best-effort guess at the sizeof() of an integral type. */ - private static long getApproximateSize(ICPPBasicType type) { + private static long getApproximateSize(IBasicType type) { switch (type.getKind()) { case eChar: return 1; case eWChar: return 2; @@ -396,12 +395,13 @@ /** * Checks whether a target integral type can represent all values of a source integral type. + * * @param target the target integral type * @param source the source integral type * @param point point for sizeof lookup * @return whether the target integral type can represent all values of the source integral type */ - public static boolean fitsIntoType(ICPPBasicType target, ICPPBasicType source, IASTNode point) { + public static boolean fitsIntoType(IBasicType target, IBasicType source, IASTNode point) { // A boolean cannot represent any other type. if (target.getKind() == Kind.eBoolean && source.getKind() != Kind.eBoolean) return false; @@ -419,9 +419,10 @@ long sizeofSource = sourceSizeAndAlignment == null ? getApproximateSize(source) : sourceSizeAndAlignment.size; long sizeofTarget = targetSizeAndAlignment == null ? getApproximateSize(target) : targetSizeAndAlignment.size; - if (sizeofSource == sizeofTarget) + if (sizeofSource == sizeofTarget) { return target.isUnsigned() == source.isUnsigned(); - else + } else { return sizeofSource < sizeofTarget; + } } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2014 Wind River Systems, 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 @@ -12,12 +12,20 @@ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IBasicType; +import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumerator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; /** * Base class for C and C++ enumerators. @@ -113,9 +121,9 @@ if (integralValue == null) { IASTNode parent= getParent(); if (parent instanceof IASTInternalEnumerationSpecifier) { - IASTInternalEnumerationSpecifier ies= (IASTInternalEnumerationSpecifier) parent; - if (ies.startValueComputation()) { // prevents infinite recursions - createEnumValues((IASTEnumerationSpecifier) parent); + IASTInternalEnumerationSpecifier enumeration= (IASTInternalEnumerationSpecifier) parent; + if (enumeration.startValueComputation()) { // Prevent infinite recursion. + computeEnumValues(enumeration); } } if (integralValue == null) { @@ -125,28 +133,104 @@ return integralValue; } - private void createEnumValues(IASTEnumerationSpecifier parent) { - IValue previousExplicitValue = null; - int delta = 0; - IASTEnumerator[] etors= parent.getEnumerators(); - for (IASTEnumerator etor : etors) { - IValue val; - IASTExpression expr= etor.getValue(); - if (expr != null) { - val= Value.create(expr, Value.MAX_RECURSION_DEPTH); - previousExplicitValue = val; - delta = 1; - } else { - if (previousExplicitValue != null) { - val = Value.incrementedValue(previousExplicitValue, delta); + private static void computeEnumValues(IASTInternalEnumerationSpecifier enumeration) { + try { + IType fixedType = null; + if (enumeration instanceof ICPPASTEnumerationSpecifier) { + IBinding binding = enumeration.getName().resolveBinding(); + if (binding instanceof ICPPEnumeration) { + fixedType = ((ICPPEnumeration) binding).getFixedType(); + } + } + IType type = fixedType == null ? CPPBasicType.INT : null; + IValue previousExplicitValue = null; + int delta = 0; + IASTEnumerator[] etors= enumeration.getEnumerators(); + for (IASTEnumerator etor : etors) { + IBinding etorBinding = etor.getName().resolveBinding(); + IValue val; + IASTExpression expr= etor.getValue(); + if (expr != null) { + val= Value.create(expr); + previousExplicitValue = val; + delta = 1; + if (fixedType == null) { + type = expr.getExpressionType(); + type = SemanticUtil.getNestedType(type, SemanticUtil.CVTYPE | SemanticUtil.TDEF); + if (etorBinding instanceof CPPEnumerator) { + ((CPPEnumerator) etorBinding).setInternalType(type); + } + } } else { - val = Value.create(delta); + if (previousExplicitValue != null) { + val = Value.incrementedValue(previousExplicitValue, delta); + } else { + val = Value.create(delta); + } + delta++; + if (fixedType == null && type instanceof IBasicType) { + type = getTypeOfIncrementedValue((IBasicType) type, val); + if (etorBinding instanceof CPPEnumerator) { + ((CPPEnumerator) etorBinding).setInternalType(type); + } + } + } + if (etor instanceof ASTEnumerator) { + ((ASTEnumerator) etor).integralValue= val; } - delta++; } - if (etor instanceof ASTEnumerator) { - ((ASTEnumerator) etor).integralValue= val; + } finally { + enumeration.finishValueComputation(); + } + } + + /** + * [dcl.enum] 7.2-5: + * "... the type of the initializing value is the same as the type of the initializing value of + * the preceding enumerator unless the incremented value is not representable in that type, in + * which case the type is an unspecified integral type sufficient to contain the incremented + * value. If no such type exists, the program is ill-formed." + * + * @param type the type of the previous value + * @param val the incremented value + * @return the type of the incremented value + */ + public static IBasicType getTypeOfIncrementedValue(IBasicType type, IValue val) { + Long numericalValue = val.numericalValue(); + if (numericalValue != null) { + long longValue = numericalValue.longValue(); + if ((type.getKind() != Kind.eInt && type.getKind() != Kind.eInt128) || + type.isShort()) { + type = type.isUnsigned() ? CPPBasicType.UNSIGNED_INT : CPPBasicType.INT; + } + if (!ArithmeticConversion.fitsIntoType(type, longValue)) { + if (!type.isUnsigned()) { + if (type.getKind() != Kind.eInt128) { + if (type.isLongLong()) { + type = CPPBasicType.UNSIGNED_INT128; + } else if (type.isLong()) { + type = CPPBasicType.UNSIGNED_LONG_LONG; + } else { + type = CPPBasicType.UNSIGNED_LONG; + } + } + } else { + if (type.getKind() == Kind.eInt128) { + if (longValue >= 0) { + type = CPPBasicType.UNSIGNED_INT128; + } + } else { + if (type.isLongLong()) { + type = CPPBasicType.INT128; + } else if (type.isLong()) { + type = CPPBasicType.LONG_LONG; + } else { + type = CPPBasicType.LONG; + } + } + } } } + return type; } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java 2015-02-11 19:19:10.000000000 +0000 @@ -60,7 +60,7 @@ } @Override - public boolean isFrozen() { + public final boolean isFrozen() { return frozen; } @@ -74,14 +74,13 @@ } public void setInactive() { - if (frozen) - throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$ + assertNotFrozen(); active= false; } - protected void assertNotFrozen() throws IllegalStateException { + protected final void assertNotFrozen() throws IllegalStateException { if (frozen) - throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$ + throw new IllegalStateException("Attempt to modify a frozen AST node"); //$NON-NLS-1$ } @Override @@ -91,7 +90,7 @@ } @Override - public ASTNodeProperty getPropertyInParent() { + public final ASTNodeProperty getPropertyInParent() { return property; } @@ -105,7 +104,7 @@ return offset; } - public int getLength() { + public final int getLength() { return length; } @@ -162,8 +161,9 @@ } protected char[] getRawSignatureChars() { - final IASTFileLocation floc= getFileLocation(); - final IASTTranslationUnit ast = getTranslationUnit(); + final IASTNode originalNode = getOriginalNode(); + final IASTFileLocation floc= originalNode.getFileLocation(); + final IASTTranslationUnit ast = originalNode.getTranslationUnit(); if (floc != null && ast != null) { ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class); if (lr != null) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java 2015-02-11 19:19:10.000000000 +0000 @@ -177,22 +177,13 @@ return type1.isSameType(type2); } - protected static IType isCompatibleArray(IType t1, IType t2) { + protected static boolean areArraysOfTheSameElementType(IType t1, IType t2) { if (t1 instanceof IArrayType && t2 instanceof IArrayType) { IArrayType a1 = (IArrayType) t1; IArrayType a2 = (IArrayType) t2; - if (!isSameType(a1.getType(), a2.getType())) { - return null; - } - if (a1.getSize() == null) { - if (a2.getSize() != null) { - return a2; - } - } else if (a2.getSize() == null) { - return a1; - } + return isSameType(a1.getType(), a2.getType()); } - return null; + return false; } /** diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2015 Wind River Systems, 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 @@ -37,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.dom.ast.INodeFactory; +import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; @@ -421,7 +422,16 @@ /** * Can be called to create a type for a type-id. */ - abstract protected IType createType(IASTTypeId typeid); + protected abstract IType createType(IASTTypeId typeid); + + /** + * Maps an index scope to the AST. + * + * @param scope a scope, possibly from index + * @return the corresponding scope in the AST, or the original scope if it doesn't have + * a counterpart in the AST. + */ + public abstract IScope mapToASTScope(IScope scope); protected T copy(T copy, CopyStyle style) { copy.setIndex(fIndex); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java 2015-02-11 19:19:10.000000000 +0000 @@ -84,9 +84,6 @@ return CharArrayUtils.equals(s1.getSignature(), s2.getSignature()); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IArrayType#getType() - */ @Override public IType getType() { return type; @@ -139,7 +136,12 @@ if (sizeExpression == null) return value= null; - return value= Value.create(sizeExpression, Value.MAX_RECURSION_DEPTH); + return value= Value.create(sizeExpression); + } + + @Override + public boolean hasSize() { + return value == Value.NOT_INITIALIZED ? sizeExpression != null : value != null; } @Override @@ -210,8 +212,6 @@ @Override @Deprecated public IASTExpression getArraySizeExpression() { - if (sizeExpression != null) - return sizeExpression; - return null; + return sizeExpression; } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java 2015-02-11 19:19:10.000000000 +0000 @@ -30,8 +30,9 @@ /** * Handles ambiguities for parameter declarations. - *
+ *
  * void function(const D*); // is D a type?
+ * 
* @since 5.0.1 */ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration { @@ -47,7 +48,7 @@ @Override protected void beforeResolution() { - // populate containing scope, so that it will not be affected by the alternative branches. + // Populate containing scope, so that it will not be affected by the alternative branches. IScope scope= CVisitor.getContainingScope(this); if (scope instanceof IASTInternalScope) { ((IASTInternalScope) scope).populateCache(); @@ -94,6 +95,7 @@ return fSimpleDecl.getAttributes(); } + @Deprecated @Override public void addAttribute(IASTAttribute attribute) { fSimpleDecl.addAttribute(attribute); @@ -114,18 +116,18 @@ final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); IASTNode nodeToReplace= this; - // handle nested ambiguities first + // Handle nested ambiguities first. owner.replace(nodeToReplace, fSimpleDecl); IASTDeclSpecifier declSpec= fSimpleDecl.getDeclSpecifier(); declSpec.accept(resolver); - // find nested names + // Find nested names. final NameCollector nameCollector= new NameCollector(); declSpec.accept(nameCollector); final IASTName[] names= nameCollector.getNames(); - // resolve names + // Resolve names. boolean hasIssue= false; for (IASTName name : names) { try { @@ -140,13 +142,13 @@ } } if (hasIssue) { - // use the alternate version + // Use the alternate version. final IASTAmbiguityParent parent = (IASTAmbiguityParent) fSimpleDecl; parent.replace(declSpec, fAltDeclSpec); parent.replace(fSimpleDecl.getDeclarators()[0], fAltDtor); } - // resolve further nested ambiguities + // Resolve further nested ambiguities. fSimpleDecl.accept(resolver); return fSimpleDecl; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerationSpecifier.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerationSpecifier.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerationSpecifier.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerationSpecifier.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,14 +1,15 @@ /******************************************************************************* - * Copyright (c) 2005, 2011 IBM Corporation and others. + * Copyright (c) 2005, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Yuan Zhang / Beth Tibbitts (IBM Research) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -23,11 +24,11 @@ */ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier implements IASTInternalEnumerationSpecifier, ICASTEnumerationSpecifier { + private IASTName fName; + private Boolean fValuesComputed; + private IASTEnumerator[] fEnumerators = IASTEnumerator.EMPTY_ENUMERATOR_ARRAY; + private int fNumEnumerators; - private IASTName name; - private boolean valuesComputed= false; - - public CASTEnumerationSpecifier() { } @@ -47,49 +48,52 @@ } protected T copy(T copy, CopyStyle style) { - copy.setName(name == null ? null : name.copy(style)); + copy.setName(fName == null ? null : fName.copy(style)); for (IASTEnumerator enumerator : getEnumerators()) { copy.addEnumerator(enumerator == null ? null : enumerator.copy(style)); } return super.copy(copy, style); } - @Override public boolean startValueComputation() { - if (valuesComputed) + if (fValuesComputed != null) return false; - valuesComputed= true; + fValuesComputed= Boolean.FALSE; return true; } @Override + public void finishValueComputation() { + fValuesComputed= Boolean.TRUE; + } + + @Override + public boolean isValueComputationInProgress() { + return fValuesComputed != null && !fValuesComputed; + } + + @Override public void addEnumerator(IASTEnumerator enumerator) { assertNotFrozen(); if (enumerator != null) { enumerator.setParent(this); enumerator.setPropertyInParent(ENUMERATOR); - enumerators = ArrayUtil.appendAt( IASTEnumerator.class, enumerators, ++enumeratorsPos, enumerator ); + fEnumerators = ArrayUtil.appendAt(fEnumerators, fNumEnumerators++, enumerator); } } - @Override public IASTEnumerator[] getEnumerators() { - if( enumerators == null ) return IASTEnumerator.EMPTY_ENUMERATOR_ARRAY; - enumerators = ArrayUtil.trimAt( IASTEnumerator.class, enumerators, enumeratorsPos ); - return enumerators; + fEnumerators = ArrayUtil.trim(fEnumerators, fNumEnumerators); + return fEnumerators; } - private IASTEnumerator [] enumerators = null; - private int enumeratorsPos=-1; - - @Override public void setName(IASTName name) { assertNotFrozen(); - this.name = name; + this.fName = name; if (name != null) { name.setParent(this); name.setPropertyInParent(ENUMERATION_NAME); @@ -98,38 +102,39 @@ @Override public IASTName getName() { - return name; + return fName; } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitDeclSpecifiers ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitDeclSpecifiers) { + switch(action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( name != null ) if( !name.accept( action ) ) return false; + if (fName != null && !fName.accept(action)) + return false; IASTEnumerator[] etors = getEnumerators(); - for ( int i = 0; i < etors.length; i++ ) { - if( !etors[i].accept( action ) ) return false; + for (int i = 0; i < etors.length; i++) { + if (!etors[i].accept(action)) + return false; } - if( action.shouldVisitDeclSpecifiers ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitDeclSpecifiers) { + switch(action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; } @Override - public int getRoleForName(IASTName n ) { - if( this.name == n ) + public int getRoleForName(IASTName n) { + if (this.fName == n) return r_definition; return r_unclear; } - } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,14 +1,15 @@ /******************************************************************************* - * Copyright (c) 2002, 2011 IBM Corporation and others. + * Copyright (c) 2002, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -21,17 +22,19 @@ import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; +import org.eclipse.cdt.internal.core.index.IIndexScope; /** * C-specific implementation of a translation unit. */ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbiguityParent { - private CScope compilationUnit = null; + private CScope compilationUnit; private final CStructMapper fStructMapper; public CASTTranslationUnit() { @@ -78,11 +81,6 @@ return ArrayUtil.removeNulls(IASTName.class, names); } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getReferences(org.eclipse.cdt.core.dom.ast.IBinding) - */ @Override public IASTName[] getReferences(IBinding binding) { if (binding instanceof IMacroBinding) @@ -106,13 +104,27 @@ accept(new CASTAmbiguityResolver()); } + @Override + public IScope mapToASTScope(IScope scope) { + if (scope instanceof IIndexScope) { + if (scope.getKind() == EScopeKind.eGlobal) + return getScope(); + if (scope instanceof ICCompositeTypeScope) { + ICompositeType type = ((ICCompositeTypeScope) scope).getCompositeType(); + type = mapToASTType(type); + return type.getCompositeScope(); + } + } + return scope; + } + /** * Maps structs from the index into this AST. */ public ICompositeType mapToASTType(ICompositeType type) { return fStructMapper.mapToAST(type); } - + @Override protected IType createType(IASTTypeId typeid) { return CVisitor.createType(typeid.getAbstractDeclarator()); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CCompositeTypeScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CCompositeTypeScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CCompositeTypeScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CCompositeTypeScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -32,39 +32,33 @@ * Implementation of scope for structs and unions. */ public class CCompositeTypeScope extends CScope implements ICCompositeTypeScope { - public CCompositeTypeScope( ICASTCompositeTypeSpecifier compTypeSpec ){ - super( compTypeSpec, EScopeKind.eClassType); + public CCompositeTypeScope(ICASTCompositeTypeSpecifier compTypeSpec) { + super(compTypeSpec, EScopeKind.eClassType); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope#getBinding(char[]) - */ @Override - public IBinding getBinding( char[] name ) { - return super.getBinding( NAMESPACE_TYPE_OTHER, name ); + public IBinding getBinding(char[] name) { + return super.getBinding(NAMESPACE_TYPE_OTHER, name); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) - */ @Override - public IBinding[] find( String name ) { - CollectNamesAction action = new CollectNamesAction( name.toCharArray() ); - getPhysicalNode().accept( action ); + public IBinding[] find(String name) { + CollectNamesAction action = new CollectNamesAction(name.toCharArray()); + getPhysicalNode().accept(action); - IASTName [] names = action.getNames(); - IBinding [] result = null; + IASTName[] names = action.getNames(); + IBinding[] result = null; for (IASTName astName : names) { IBinding b = astName.resolveBinding(); - if( b == null ) continue; + if (b == null) continue; try { - if( b.getScope() == this ) - result = ArrayUtil.append( IBinding.class, result, b ); - } catch ( DOMException e ) { + if (b.getScope() == this) + result = ArrayUtil.append(IBinding.class, result, b); + } catch (DOMException e) { } } - return ArrayUtil.trim( IBinding.class, result ); + return ArrayUtil.trim(IBinding.class, result); } @Override @@ -74,7 +68,7 @@ if (binding instanceof ICompositeType) return (ICompositeType) binding; - return new CStructure.CStructureProblem(compSpec.getName(), ISemanticProblem.BINDING_NO_CLASS, compSpec.getName().toCharArray() ); + return new CStructure.CStructureProblem(compSpec.getName(), ISemanticProblem.BINDING_NO_CLASS, compSpec.getName().toCharArray()); } @Override diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java 2015-02-11 19:19:10.000000000 +0000 @@ -11,6 +11,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -26,19 +29,30 @@ import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; -import org.eclipse.cdt.internal.core.dom.parser.IInternalVariable; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.core.runtime.PlatformObject; /** * Binding for a global or a local variable, serves as base class for fields. */ -public class CVariable extends PlatformObject implements IInternalVariable, ICInternalBinding { +public class CVariable extends PlatformObject implements ICInternalBinding, IVariable { private IASTName[] declarations = null; private IType type = null; + + /** + * The set of CVariable objects for which initial value computation is in progress on each thread. + * This is used to guard against recursion during initial value computation. + */ + private static final ThreadLocal> fInitialValueInProgress = new ThreadLocal>() { + @Override + protected Set initialValue() { + return new HashSet<>(); + } + }; public CVariable(IASTName name) { declarations = new IASTName[] { name }; @@ -144,24 +158,27 @@ @Override public IValue getInitialValue() { - return getInitialValue(Value.MAX_RECURSION_DEPTH); - } - - @Override - public IValue getInitialValue(int maxDepth) { - if (declarations != null) { - for (IASTName decl : declarations) { - if (decl == null) - break; - final IValue val = getInitialValue(decl, maxDepth); - if (val != null) - return val; + Set recursionProtectionSet = fInitialValueInProgress.get(); + if (!recursionProtectionSet.add(this)) { + return Value.UNKNOWN; + } + try { + if (declarations != null) { + for (IASTName decl : declarations) { + if (decl == null) + break; + final IValue val = getInitialValue(decl); + if (val != null) + return val; + } } + } finally { + recursionProtectionSet.remove(this); } return null; } - private IValue getInitialValue(IASTName name, int maxDepth) { + private IValue getInitialValue(IASTName name) { IASTDeclarator dtor = findDeclarator(name); if (dtor != null) { IASTInitializer init = dtor.getInitializer(); @@ -169,7 +186,7 @@ final IASTInitializerClause initClause = ((IASTEqualsInitializer) init) .getInitializerClause(); if (initClause instanceof IASTExpression) { - return Value.create((IASTExpression) initClause, maxDepth); + return Value.create((IASTExpression) initClause); } } if (init != null) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java 2015-02-11 19:19:10.000000000 +0000 @@ -797,8 +797,8 @@ return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION, name.toCharArray()); } else if (binding instanceof IVariable) { t2 = ((IVariable) binding).getType(); - if (t1 != null && t2 != null && ( - t1.isSameType(t2) || isCompatibleArray(t1, t2) != null)) { + if (t1 != null && t2 != null && + (areArraysOfTheSameElementType(t1, t2) || t1.isSameType(t2))) { if (binding instanceof CVariable) ((CVariable) binding).addDeclaration(name); } else { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 2015-02-11 19:19:10.000000000 +0000 @@ -612,6 +612,7 @@ case IToken.t_sizeof: return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), IASTTypeIdExpression.op_sizeof, IASTUnaryExpression.op_sizeof, ctx, strat); + case IToken.t_alignof: case IGCCToken.t___alignof__: return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx, strat); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java 2015-02-11 19:19:10.000000000 +0000 @@ -15,11 +15,13 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; +import java.util.Deque; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -95,7 +97,7 @@ return new IBinding[] { new ProblemBinding(node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray()) }; } } - ObjectSet resultSet = new ObjectSet(2); + ObjectSet resultSet = new ObjectSet<>(2); IASTDeclaration[] members = host.getCompositeTypeSpecifier().getMembers(); for (IASTDeclaration decl : members) { while (decl instanceof ICPPASTTemplateDeclaration) { @@ -134,7 +136,7 @@ * A class is considered a friend of itself. * @param binding a binding. * @param classType a class. - * @return true if binding is a friend of classType. + * @return {@code true} if {@code binding} is a friend of {@code classType}. */ public static boolean isFriend(IBinding binding, ICPPClassType classType) { IType type; @@ -282,7 +284,7 @@ * @return An array of base classes in arbitrary order. */ public static ICPPClassType[] getAllBases(ICPPClassType classType, IASTNode point) { - HashSet result= new HashSet(); + HashSet result= new HashSet<>(); result.add(classType); getAllBases(classType, result, point); result.remove(classType); @@ -304,7 +306,7 @@ /** * Checks inheritance relationship between two classes. - * @return true if {@code subclass} is a subclass of {@code superclass}. + * @return {@code true} if {@code subclass} is a subclass of {@code superclass}. */ public static boolean isSubclass(ICPPClassType subclass, ICPPClassType superclass, IASTNode point) { ICPPBase[] bases= getBases(subclass, point); @@ -348,7 +350,7 @@ * include methods declared in base classes. */ public static ObjectSet getOwnMethods(ICPPClassType classType, IASTNode point) { - ObjectSet set= new ObjectSet(4); + ObjectSet set= new ObjectSet<>(4); set.addAll(ClassTypeHelper.getDeclaredMethods(classType, point)); set.addAll(getImplicitMethods(classType, point)); return set; @@ -585,8 +587,8 @@ if (mcl == null) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; - final ArrayList result= new ArrayList(); - final HashMap virtualInClass= new HashMap(); + final ArrayList result= new ArrayList<>(); + final HashMap virtualInClass= new HashMap<>(); final ICPPFunctionType methodType= method.getType(); virtualInClass.put(mcl, method.isVirtual()); @@ -679,7 +681,7 @@ public static ICPPMethod[] findOverriders(ICPPClassType[] subclasses, ICPPMethod method) { final char[] mname= method.getNameCharArray(); final ICPPFunctionType mft= method.getType(); - final ArrayList result= new ArrayList(); + final ArrayList result= new ArrayList<>(); for (ICPPClassType subClass : subclasses) { ICPPMethod[] methods= subClass.getDeclaredMethods(); for (ICPPMethod candidate : methods) { @@ -693,14 +695,15 @@ } private static ICPPClassType[] getSubClasses(IIndex index, ICPPClassType mcl) throws CoreException { - List result= new LinkedList(); - HashSet handled= new HashSet(); + Deque result= new ArrayDeque<>(); + HashSet handled= new HashSet<>(); getSubClasses(index, mcl, result, handled); - result.remove(0); + result.removeFirst(); return result.toArray(new ICPPClassType[result.size()]); } - private static void getSubClasses(IIndex index, ICPPBinding classOrTypedef, List result, HashSet handled) throws CoreException { + private static void getSubClasses(IIndex index, ICPPBinding classOrTypedef, + Collection result, HashSet handled) throws CoreException { if (!(classOrTypedef instanceof IType)) return; @@ -778,7 +781,7 @@ ICPPParameter[] parameters = method.getParameters(); if (parameters.length == 0) return Collections.emptyList(); - List types = new ArrayList(parameters.length); + List types = new ArrayList<>(parameters.length); for (ICPPParameter parameter : parameters) { if (!parameter.hasDefaultValue() && !parameter.isParameterPack()) types.add(parameter.getType()); @@ -800,7 +803,7 @@ if (kind == MethodKind.OTHER) return null; - List inheritedTypeids = new ArrayList(); + List inheritedTypeids = new ArrayList<>(); ICPPClassType[] bases= getAllBases(owner, point); for (ICPPClassType base : bases) { if (!(base instanceof ICPPDeferredClassInstance)) { @@ -874,11 +877,11 @@ } /** - * Returns the visibility for a given member in the host. - * Throws an IllegalArgumentException if member is not a member of host + * Returns the visibility for a given {@code member} in the {@code host}. + * Throws an IllegalArgumentException if {@code member} is not a member of {@code host} * * @param classType The class to get the member's visibility specifier of. - * @return the visibility of the member. + * @return the visibility of the {@code member}. */ public static int getVisibility(ICPPInternalClassTypeMixinHost classType, IBinding member) { if (classType.getDefinition() == null) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -84,9 +84,14 @@ if (sizeExpression == null) return value= null; - return value= Value.create(sizeExpression, Value.MAX_RECURSION_DEPTH); + return value= Value.create(sizeExpression); } - + + @Override + public boolean hasSize() { + return value == Value.NOT_INITIALIZED ? sizeExpression != null : value != null; + } + @Override @Deprecated public IASTExpression getArraySizeExpression() { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -9,6 +9,7 @@ * John Camelon (IBM) - Initial API and implementation * Bryan Wilkinson (QNX) * Markus Schorn (Wind River Systems) + * Michael Woski *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -19,10 +20,14 @@ import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; @@ -30,12 +35,10 @@ * Base class specifier */ public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier, ICPPASTCompletionContext { - private boolean isVirtual; private int visibility; private ICPPASTNameSpecifier nameSpecifier; private boolean fIsPackExpansion; - public CPPASTBaseSpecifier() { } @@ -121,9 +124,9 @@ public boolean accept(ASTVisitor action) { if (action.shouldVisitBaseSpecifiers) { switch (action.visit(this)) { - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } @@ -157,12 +160,23 @@ } for (IBinding binding : bindings) { - if (binding instanceof ICPPClassType) { - ICPPClassType base = (ICPPClassType) binding; - int key = base.getKey(); - if (key == ICPPClassType.k_class && - (classType == null || !base.isSameType(classType))) { - filtered.add(base); + if (binding instanceof IType) { + IType type = (IType) binding; + + while (type instanceof ITypedef || type instanceof ICPPAliasTemplate) { + type = type instanceof ITypedef ? + ((ITypedef) type).getType() : ((ICPPAliasTemplate) type).getType(); + } + + if (type instanceof ICPPClassType) { + int key = ((ICPPClassType) type).getKey(); + if ((key == ICPPClassType.k_class || key == ICPPClassType.k_struct + || type instanceof ICPPDeferredClassInstance || type instanceof ICPPUnknownMemberClass) + && (classType == null || !type.isSameType(classType))) { + filtered.add(binding); + } + } else if (type instanceof ICPPTemplateTypeParameter) { + filtered.add(binding); } } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java 2015-02-11 19:19:10.000000000 +0000 @@ -40,7 +40,7 @@ private ICPPASTInitializerClause operand2; private ICPPEvaluation evaluation; - private IASTImplicitName[] implicitNames = null; + private IASTImplicitName[] implicitNames; public CPPASTBinaryExpression() { } @@ -58,10 +58,9 @@ @Override public CPPASTBinaryExpression copy(CopyStyle style) { - CPPASTBinaryExpression copy = new CPPASTBinaryExpression(); - copy.op = op; - copy.setOperand1(operand1 == null ? null : operand1.copy(style)); - copy.setInitOperand2(operand2 == null ? null : operand2.copy(style)); + CPPASTBinaryExpression copy = new CPPASTBinaryExpression(op, + operand1 == null ? null : operand1.copy(style), + operand2 == null ? null : operand2.copy(style)); return copy(copy, style); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -65,9 +65,9 @@ public boolean accept(ASTVisitor visitor) { if (visitor.shouldVisitCaptures) { switch (visitor.visit(this)) { - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java 2015-02-11 19:19:10.000000000 +0000 @@ -9,6 +9,7 @@ * John Camelon (IBM) - Initial API and implementation * Markus Schorn (Wind River Systems) * Thomas Corbat (IFS) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -21,7 +22,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalEnumerationSpecifier; /** - * AST node for c++ enumeration specifiers. + * AST node for C++ enumeration specifiers. */ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier implements IASTInternalEnumerationSpecifier, ICPPASTEnumerationSpecifier { @@ -30,10 +31,10 @@ private IASTName fName; private ICPPASTDeclSpecifier fBaseType; - private IASTEnumerator[] fItems; - private int fItemPos= -1; + private IASTEnumerator[] fEnumerators = IASTEnumerator.EMPTY_ENUMERATOR_ARRAY; + private int fNumEnumerators; - private boolean fValuesComputed; + private Boolean fValuesComputed; private CPPEnumScope fScope; public CPPASTEnumerationSpecifier() { @@ -52,9 +53,9 @@ @Override public CPPASTEnumerationSpecifier copy(CopyStyle style) { - CPPASTEnumerationSpecifier copy = - new CPPASTEnumerationSpecifier(fIsScoped, fName == null ? null : fName.copy(style), - fBaseType == null ? null : fBaseType.copy(style)); + CPPASTEnumerationSpecifier copy = new CPPASTEnumerationSpecifier(fIsScoped, + fName == null ? null : fName.copy(style), + fBaseType == null ? null : fBaseType.copy(style)); copy.fIsOpaque = fIsOpaque; for (IASTEnumerator enumerator : getEnumerators()) { copy.addEnumerator(enumerator == null ? null : enumerator.copy(style)); @@ -64,30 +65,37 @@ @Override public boolean startValueComputation() { - if (fValuesComputed) + if (fValuesComputed != null) return false; - fValuesComputed= true; + fValuesComputed= Boolean.FALSE; return true; } @Override + public void finishValueComputation() { + fValuesComputed= Boolean.TRUE; + } + + @Override + public boolean isValueComputationInProgress() { + return fValuesComputed != null && !fValuesComputed; + } + + @Override public void addEnumerator(IASTEnumerator enumerator) { assertNotFrozen(); if (enumerator != null) { enumerator.setParent(this); enumerator.setPropertyInParent(ENUMERATOR); - fItems = ArrayUtil.appendAt( IASTEnumerator.class, fItems, ++fItemPos, enumerator ); + fEnumerators = ArrayUtil.appendAt(fEnumerators, fNumEnumerators++, enumerator); } } @Override public IASTEnumerator[] getEnumerators() { - if (fItems == null) - return IASTEnumerator.EMPTY_ENUMERATOR_ARRAY; - - fItems = ArrayUtil.trimAt(IASTEnumerator.class, fItems, fItemPos); - return fItems; + fEnumerators = ArrayUtil.trim(fEnumerators, fNumEnumerators); + return fEnumerators; } @Override diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -44,6 +44,7 @@ private boolean isVolatile; private boolean isConst; private boolean isMutable; + private RefQualifier refQualifier; private ICPPFunctionScope scope; @@ -67,6 +68,7 @@ copy.isVolatile = isVolatile; copy.isConst = isConst; copy.isMutable = isMutable; + copy.refQualifier = refQualifier; for (IASTParameterDeclaration param : getParameters()) { copy.addParameterDeclaration(param == null ? null : param.copy(style)); @@ -213,6 +215,17 @@ } @Override + public RefQualifier getRefQualifier() { + return refQualifier; + } + + @Override + public void setRefQualifier(RefQualifier value) { + assertNotFrozen(); + refQualifier = value; + } + + @Override @Deprecated public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer[] getConstructorChain() { if (ASTQueries.findTypeRelevantDeclarator(this) == this) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLambdaExpression.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLambdaExpression.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLambdaExpression.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLambdaExpression.java 2015-02-11 19:19:10.000000000 +0000 @@ -113,9 +113,9 @@ public boolean accept(ASTVisitor visitor) { if (visitor.shouldVisitExpressions) { switch (visitor.visit(this)) { - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java 2015-02-11 19:19:10.000000000 +0000 @@ -55,7 +55,7 @@ // exceeds MAX_RESOLUTION_DEPTH. If the resolution depth exceeds // MAX_RESOLUTION_DEPTH + 1, it means that attempting to create the // recursion resolving binding has led us back to trying to resolve - // the bidning for this name again, so the recursion isn't broken. + // the binding for this name again, so the recursion isn't broken. // This can happen because the constructor of RecursionResolvingBinding // calls ProblemBinding.getMessage(), which can try to do name // resolution to build an argument string if one wasn't provided in the diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -37,13 +37,16 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; +import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.c.CASTExpressionList; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId; import org.eclipse.core.runtime.Assert; - +/** + * Represents a new expression [expr.new]. + */ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression, IASTAmbiguityParent { private IASTInitializerClause[] placement; private IASTTypeId typeId; @@ -267,7 +270,7 @@ @Override public ICPPEvaluation getEvaluation() { if (fEvaluation == null) { - IType t = CPPVisitor.createType(getTypeId()); + IType t = typeId != null ? CPPVisitor.createType(typeId) : ProblemType.UNKNOWN_FOR_EXPRESSION; if (t instanceof IArrayType) { t = ((IArrayType) t).getType(); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier; @@ -41,6 +42,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.model.IEnumeration; import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.util.ArrayUtil; @@ -325,9 +327,20 @@ @Override public IBinding[] findBindings(IASTName n, boolean isPrefix, String[] namespaces) { IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces); - + if (fQualifierPos >= 0) { IBinding binding = fQualifier[fQualifierPos].resolveBinding(); + + while (binding instanceof ITypedef) { + ITypedef typedef = (ITypedef) binding; + IType type = typedef.getType(); + if (type instanceof IBinding) { + binding = (IBinding) type; + } else { + binding = null; + } + } + if (binding instanceof ICPPClassType) { ICPPClassType classType = (ICPPClassType) binding; final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration; @@ -371,19 +384,21 @@ return false; } - private List filterClassScopeBindings(ICPPClassType classType, - IBinding[] bindings, final boolean isDeclaration) { + private List filterClassScopeBindings(ICPPClassType classType, IBinding[] bindings, + final boolean isDeclaration) { List filtered = new ArrayList(); - final boolean canBeFieldAccess= canBeFieldAccess(classType); + final boolean canBeFieldAccess = canBeFieldAccess(classType); + final IBinding templateDefinition = (classType instanceof ICPPTemplateInstance) + ? ((ICPPTemplateInstance) classType).getTemplateDefinition() : null; for (final IBinding binding : bindings) { if (binding instanceof IField) { IField field = (IField) binding; - if (!canBeFieldAccess && !field.isStatic()) + if (!canBeFieldAccess && !field.isStatic()) continue; } else if (binding instanceof ICPPMethod) { ICPPMethod method = (ICPPMethod) binding; - if (method.isImplicit()) + if (method.isImplicit()) continue; if (!isDeclaration) { if (method.isDestructor() || method instanceof ICPPConstructor @@ -393,14 +408,17 @@ } else if (binding instanceof IEnumerator || binding instanceof IEnumeration) { if (isDeclaration) continue; + } else if (templateDefinition == binding) { + // This solves bug 456101 (template instance refering to itself). + // A:: should not get a binding to its own template definition. + continue; } else if (binding instanceof IType) { - IType type = (IType) binding; - if (type.isSameType(classType)) + if (classType.isSameType((IType) binding)) continue; - } + } filtered.add(binding); } - + return filtered; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java 2015-02-11 19:19:10.000000000 +0000 @@ -28,8 +28,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId; -public class CPPASTSimpleTypeConstructorExpression extends ASTNode implements - ICPPASTSimpleTypeConstructorExpression { +public class CPPASTSimpleTypeConstructorExpression extends ASTNode + implements ICPPASTSimpleTypeConstructorExpression { private ICPPASTDeclSpecifier fDeclSpec; private IASTInitializer fInitializer; private ICPPEvaluation fEvaluation; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2011, 2014 Wind River Systems, 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 @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -22,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; @@ -64,7 +66,7 @@ for (BranchPoint v= fVariants; v != null; v= v.getNext()) { Variant selected= null; int bestCount= 0; - for (Variant q= v.getFirstVariant(); q != null ; q=q.getNext()) { + for (Variant q= v.getFirstVariant(); q != null ; q= q.getNext()) { final IASTName[] templateNames = q.getTemplateNames(); if (templateNames.length > bestCount) { // Don't check branch-points inside of a selected variant. @@ -72,7 +74,7 @@ if (((ASTNode) expression).getOffset() < minOffset) break; - // Setup the ast to use the alternative + // Setup the AST to use the alternative. owner.replace(nodeToReplace, expression); nodeToReplace= resolveNestedAmbiguities(expression, resolver); @@ -84,7 +86,7 @@ } } - // Adjust the operator sequence + // Adjust the operator sequence. if (selected != null) { minOffset= selected.getRightOffset(); BinaryOperator targetOp = selected.getTargetOperator(); @@ -117,7 +119,7 @@ return -1; count++; } else if (b instanceof ICPPSpecialization || b instanceof ICPPTemplateDefinition - || b instanceof ICPPConstructor + || b instanceof ICPPAliasTemplateInstance || b instanceof ICPPConstructor || (b instanceof IFunction && b instanceof ICPPUnknownBinding)) { count++; } else { @@ -141,7 +143,7 @@ @Override public IASTNode[] getNodes() { if (fNodes == null) { - List nl= new ArrayList(); + List nl= new ArrayList<>(); BinaryOperator op= fEndOperator; while (op != null) { nl.add(op.getExpression()); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java 2015-02-11 19:19:10.000000000 +0000 @@ -143,7 +143,7 @@ buf.append(arg.getRawSignature()); cleanupWhitespace= true; } else if (arg instanceof IASTExpression) { - IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH); + IValue value= Value.create((IASTExpression) arg); if (value != Value.UNKNOWN && !Value.isDependentValue(value)) { buf.append(value.getSignature()); } else { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. + * Copyright (c) 2004, 2015 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 @@ -8,6 +8,7 @@ * Contributors: * IBM - Initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -149,29 +150,33 @@ return ParserLanguage.CPP; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLinkage() - */ @Override public ILinkage getLinkage() { return Linkage.CPP_LINKAGE; } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener#skippedFile(org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent) - */ @Override public void skippedFile(int offset, InternalFileContent fileContent) { super.skippedFile(offset, fileContent); fScopeMapper.registerAdditionalDirectives(offset, fileContent.getUsingDirectives()); } - - // bug 217102: namespace scopes from the index have to be mapped back to the AST. - public IScope mapToASTScope(IIndexScope scope) { - return fScopeMapper.mapToASTScope(scope); + + @Override + public IScope mapToASTScope(IScope scope) { + if (scope instanceof IIndexScope) { + return fScopeMapper.mapToASTScope((IIndexScope) scope); + } + return scope; } - // bug 262719: class types from the index have to be mapped back to the AST. + /** + * Maps a class type to the AST. + * + * @param binding a class type, possibly from index + * @param point a lookup point in the AST + * @return the corresponding class in the AST, or the original class type if it doesn't have + * a counterpart in the AST. + */ public ICPPClassType mapToAST(ICPPClassType binding, IASTNode point) { return fScopeMapper.mapToAST(binding, point); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java 2015-02-11 19:19:10.000000000 +0000 @@ -89,6 +89,7 @@ } @Override + @Deprecated public IName getBaseClassSpecifierName() { return base.getName(); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -31,11 +31,22 @@ * Built-in c++ type. */ public class CPPBasicType implements ICPPBasicType, ISerializableType { - private static final int FROM_STRING_LITERAL = 1 << 31; public static final CPPBasicType BOOLEAN = new CPPBasicType(Kind.eBoolean, 0, null); public static final CPPBasicType NULL_PTR = new CPPBasicType(Kind.eNullPtr, 0, null); public static final CPPBasicType UNSPECIFIED_TYPE = new CPPBasicType(Kind.eUnspecified, 0); - + public static final CPPBasicType SHORT = new CPPBasicType(Kind.eInt, IBasicType.IS_SHORT); + public static final CPPBasicType INT = new CPPBasicType(Kind.eInt, 0); + public static final CPPBasicType LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG); + public static final CPPBasicType LONG_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG_LONG); + public static final CPPBasicType INT128 = new CPPBasicType(Kind.eInt128, 0); + public static final CPPBasicType UNSIGNED_SHORT = new CPPBasicType(Kind.eInt, IBasicType.IS_SHORT | IBasicType.IS_UNSIGNED); + public static final CPPBasicType UNSIGNED_INT = new CPPBasicType(Kind.eInt, IBasicType.IS_UNSIGNED); + public static final CPPBasicType UNSIGNED_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED); + public static final CPPBasicType UNSIGNED_LONG_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG_LONG | IBasicType.IS_UNSIGNED); + public static final CPPBasicType UNSIGNED_INT128 = new CPPBasicType(Kind.eInt128, IBasicType.IS_UNSIGNED); + + private static final int FROM_STRING_LITERAL = 1 << 31; + private final Kind fKind; private final int fModifiers; private Long fAssociatedValue; @@ -58,7 +69,7 @@ } fModifiers= qualifiers; if (expression instanceof ICPPASTInitializerClause) { - fAssociatedValue = Value.create(expression, Value.MAX_RECURSION_DEPTH).numericalValue(); + fAssociatedValue = Value.create(expression).numericalValue(); } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecializationSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecializationSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecializationSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecializationSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,4 +1,4 @@ - /******************************************************************************* +/******************************************************************************* * Copyright (c) 2009, 2011 Wind River Systems, 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 @@ -35,7 +35,8 @@ private final ICPPClassTemplate fClassTemplate; private final ICPPTemplateArgument[] fArguments; - public CPPClassTemplatePartialSpecializationSpecialization(ICPPClassTemplatePartialSpecialization orig, ICPPTemplateParameterMap argumentMap, ICPPClassTemplate template, + public CPPClassTemplatePartialSpecializationSpecialization(ICPPClassTemplatePartialSpecialization orig, + ICPPTemplateParameterMap argumentMap, ICPPClassTemplate template, ICPPTemplateArgument[] args) throws DOMException { super(orig, template.getOwner(), argumentMap); fClassTemplate= template; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClosureType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClosureType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClosureType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClosureType.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2013 Wind River Systems, Inc. and others. + * Copyright (c) 2010, 2014 Wind River Systems, 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 @@ -102,7 +102,7 @@ // Function call operator final IType returnType= getReturnType(); final IType[] parameterTypes= getParameterTypes(); - ft= new CPPFunctionType(returnType, parameterTypes, !isMutable(), false, false); + ft= new CPPFunctionType(returnType, parameterTypes, !isMutable(), false, false, false, false); ICPPParameter[] params = new ICPPParameter[parameterTypes.length]; for (int i = 0; i < params.length; i++) { @@ -117,7 +117,7 @@ // Conversion operator if (needConversionOperator) { final CPPFunctionType conversionTarget = new CPPFunctionType(returnType, parameterTypes); - ft= new CPPFunctionType(conversionTarget, IType.EMPTY_TYPE_ARRAY, true, false, false); + ft= new CPPFunctionType(conversionTarget, IType.EMPTY_TYPE_ARRAY, true, false, false, false, false); m= new CPPImplicitMethod(scope, CPPASTConversionName.createName(conversionTarget, null), ft, params); result[5]= m; } @@ -128,6 +128,11 @@ return getMethods()[4]; } + public ICPPMethod getConversionOperator() { + ICPPMethod[] methods = getMethods(); + return methods.length >= 6 ? methods[5] : null; + } + private boolean isMutable() { ICPPASTFunctionDeclarator lambdaDtor = fLambdaExpression.getDeclarator(); return lambdaDtor != null && lambdaDtor.isMutable(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java 2015-02-11 19:19:10.000000000 +0000 @@ -34,6 +34,7 @@ * Creates a CPPDeferredFunction given a set of overloaded functions * (some of which may be templates) that the function might resolve to. * At least one candidate must be provided. + * * @param candidates a set of overloaded functions, some of which may be templates * @return the constructed CPPDeferredFunction */ @@ -47,7 +48,8 @@ /** * Creates a CPPDeferredFunction given a name. This is for cases where there - * are no candidates that could be passed to createForCandidates(). + * are no candidates that could be passed to {@link #createForCandidates}. + * * @param name the name of the function * @return the constructed CPPDeferredFunction */ diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java 2015-02-11 19:19:10.000000000 +0000 @@ -47,7 +47,7 @@ import org.eclipse.core.runtime.PlatformObject; /** - * Enumerations in C++ + * Enumeration in C++ */ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, ICPPInternalBinding { private static final IASTName NOT_INITIALIZED = CPPASTName.NOT_INITIALIZED; @@ -90,8 +90,8 @@ private Long fMaxValue; private Long fMinValue; - private ICPPEnumeration fIndexBinding= null; - private boolean fSearchedIndex= false; + private ICPPEnumeration fIndexBinding; + private boolean fSearchedIndex; public CPPEnumeration(ICPPASTEnumerationSpecifier spec, IType fixedType) { final IASTName name = spec.getName(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerationSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerationSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerationSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerationSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Nathan Ridge and others. + * Copyright (c) 2013, 2014 Nathan Ridge 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 @@ -8,35 +8,84 @@ * Contributors: * Nathan Ridge - Initial API and implementation * Marc-Andre Laperle (Ericsson) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumerator; 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.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.internal.core.dom.parser.ASTEnumerator; +import org.eclipse.cdt.internal.core.dom.parser.Value; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; /** * Binding for a specialization of an enumeration. */ public class CPPEnumerationSpecialization extends CPPSpecialization implements ICPPEnumerationSpecialization { - private IEnumerator[] fEnumerators; + private final IEnumerator[] fEnumerators; private final IType fFixedType; + private boolean fInitializationComplete; - public CPPEnumerationSpecialization(ICPPEnumeration specialized, IBinding owner, + public static IBinding createInstance(ICPPEnumeration enumeration, + ICPPClassSpecialization owner, ICPPTemplateParameterMap tpMap, IASTNode point) { + ICPPClassSpecialization within = CPPTemplates.getSpecializationContext(owner); + IType fixedType = enumeration.getFixedType(); + if (fixedType != null) + fixedType = CPPTemplates.instantiateType(fixedType, tpMap, -1, within, point); + CPPEnumerationSpecialization specializedEnumeration = + new CPPEnumerationSpecialization(enumeration, owner, tpMap, fixedType); + specializedEnumeration.initialize(point); + return specializedEnumeration; + } + + private CPPEnumerationSpecialization(ICPPEnumeration specialized, IBinding owner, ICPPTemplateParameterMap argumentMap, IType fixedType) { super(specialized, owner, argumentMap); fFixedType = fixedType; + fEnumerators = new IEnumerator[specialized.getEnumerators().length]; + } + + private void initialize(IASTNode point) { + ICPPTemplateParameterMap tpMap = getTemplateParameterMap(); + IEnumerator[] enumerators = getSpecializedBinding().getEnumerators(); + IType previousInternalType = CPPBasicType.INT; + for (int i = 0; i < enumerators.length; ++i) { + IEnumerator enumerator = enumerators[i]; + IValue specializedValue = CPPTemplates.instantiateValue(enumerator.getValue(), tpMap, -1, + this, Value.MAX_RECURSION_DEPTH, point); + IType internalType = null; + if (fFixedType == null && enumerator instanceof ICPPInternalEnumerator) { + internalType = ((ICPPInternalEnumerator) enumerator).getInternalType(); + if (internalType != null) { + internalType = CPPTemplates.instantiateType(internalType, tpMap, -1, this, point); + } else if (previousInternalType instanceof IBasicType) { + internalType = ASTEnumerator.getTypeOfIncrementedValue( + (IBasicType) previousInternalType, specializedValue); + } + if (internalType != null) { + previousInternalType = internalType; + } + } + fEnumerators[i] = new CPPEnumeratorSpecialization(enumerator, this, tpMap, specializedValue, + internalType); + } + fInitializationComplete = true; } - public void setEnumerators(IEnumerator[] enumerators) { - fEnumerators = enumerators; + public boolean isInitializing() { + return !fInitializationComplete; } @Override @@ -99,13 +148,14 @@ return enumerator; } - // The specialized enumerators are already computed, just need - // to look up the right one. + // The specialized enumerators are already computed, just need to look up the right one. IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators(); for (int i = 0; i < fEnumerators.length; ++i) { - if (enumerator.equals(unspecializedEnumerators[i])) - return fEnumerators[i]; + if (enumerator.equals(unspecializedEnumerators[i])) { + IEnumerator specializedEnumerator = fEnumerators[i]; + return specializedEnumerator == null ? enumerator : specializedEnumerator; + } } - return null; + return enumerator; } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumerator.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -8,32 +8,36 @@ * Contributors: * Andrew Niefer (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.DOMException; -import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.ASTEnumerator; +import org.eclipse.cdt.internal.core.dom.parser.IASTInternalEnumerationSpecifier; +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.semantics.CPPVisitor; import org.eclipse.core.runtime.PlatformObject; /** - * Binding for a c++ enumerator. + * Binding for a C++ enumerator. */ -public class CPPEnumerator extends PlatformObject implements IEnumerator, ICPPInternalBinding { +public class CPPEnumerator extends PlatformObject + implements ICPPInternalEnumerator, ICPPInternalBinding { private IASTName enumName; + private IType internalType; /** * @param enumerator @@ -43,82 +47,80 @@ enumerator.setBinding(this); } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations() - */ @Override public IASTNode[] getDeclarations() { return null; } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition() - */ @Override public IASTNode getDefinition() { return enumName; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() - */ @Override public String getName() { return new String(getNameCharArray()); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray() - */ @Override public char[] getNameCharArray() { return enumName.getSimpleID(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() - */ @Override public IScope getScope() { return CPPVisitor.getContainingScope(enumName); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode() - */ public IASTNode getPhysicalNode() { return enumName; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IEnumerator#getType() - */ @Override public IType getType() { IASTEnumerator etor = (IASTEnumerator) enumName.getParent(); - IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier) etor.getParent(); + IASTInternalEnumerationSpecifier enumSpec = (IASTInternalEnumerationSpecifier) etor.getParent(); + if (enumSpec.isValueComputationInProgress()) { + // During value computation enumerators can be referenced only by initializer + // expressions of other enumerators of the same enumeration. Return the internal type + // of the enumerator ([dcl.enum] 7.2-5). + if (internalType != null) + return internalType; + ICPPEnumeration binding = (ICPPEnumeration) enumSpec.getName().resolveBinding(); + IType fixedType = binding.getFixedType(); + return fixedType != null ? fixedType : ProblemType.UNKNOWN_FOR_EXPRESSION; + } return (IType) enumSpec.getName().resolveBinding(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName() - */ + @Override + public IType getInternalType() { + if (internalType == null) { + getValue(); // Trigger value and internal type computation. + } + return internalType; + } + + /** + * Sets the internal type of the enumerator. The enumerator has this type between the opening + * and the closing braces of the enumeration ([dcl.enum] 7.2-5). + * + * @param type the integral type of the enumerator's initializing value + */ + public void setInternalType(IType type) { + internalType = type; + } + @Override public String[] getQualifiedName() { return CPPVisitor.getQualifiedName(this); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray() - */ @Override public char[][] getQualifiedNameCharArray() { return CPPVisitor.getQualifiedNameCharArray(this); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified() - */ @Override public boolean isGloballyQualified() throws DOMException { IScope scope = getScope(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeratorSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeratorSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeratorSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeratorSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Nathan Ridge. + * Copyright (c) 2013, 2014 Nathan Ridge. * 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 @@ -7,6 +7,7 @@ * * Contributors: * Nathan Ridge - Initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -19,13 +20,15 @@ /** * Binding for a specialization of an enumerator. */ -public class CPPEnumeratorSpecialization extends CPPSpecialization implements IEnumerator { +public class CPPEnumeratorSpecialization extends CPPSpecialization implements ICPPInternalEnumerator { private final IValue fValue; + private final IType fInternalType; public CPPEnumeratorSpecialization(IEnumerator specialized, ICPPEnumerationSpecialization owner, - ICPPTemplateParameterMap argumentMap, IValue value) { + ICPPTemplateParameterMap argumentMap, IValue value, IType internalType) { super(specialized, owner, argumentMap); fValue = value; + fInternalType = internalType; } @Override @@ -35,11 +38,23 @@ @Override public IType getType() { - return getOwner(); + ICPPEnumerationSpecialization owner = getOwner(); + if (((CPPEnumerationSpecialization) owner).isInitializing()) { + // During enumeration instantiation enumerators can be referenced only by initializer + // expressions of other enumerators of the same enumeration. Return the internal type + // of the enumerator ([dcl.enum] 7.2-5). + return fInternalType; + } + return owner; } @Override public IValue getValue() { return fValue; } + + @Override + public IType getInternalType() { + return fInternalType; + } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -16,7 +16,6 @@ import java.util.List; import org.eclipse.cdt.core.dom.IName; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -84,7 +83,7 @@ } @Override - public IScope getParent() throws DOMException { + public IScope getParent() { //we can't just resolve the function and get its parent scope, since there are cases where that //could loop since resolving functions requires resolving their parameter types IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) getPhysicalNode(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -31,18 +31,22 @@ private final IType returnType; private final boolean isConst; private final boolean isVolatile; + private final boolean hasRefQualifier; + private final boolean isRValueReference; private final boolean takesVarargs; public CPPFunctionType(IType returnType, IType[] types) { - this(returnType, types, false, false, false); + this(returnType, types, false, false, false, false, false); } public CPPFunctionType(IType returnType, IType[] types, boolean isConst, boolean isVolatile, - boolean takesVarargs) { + boolean hasRefQualifier, boolean isRValueReference, boolean takesVarargs) { this.returnType = returnType; this.parameters = types; this.isConst = isConst; this.isVolatile= isVolatile; + this.hasRefQualifier = hasRefQualifier; + this.isRValueReference = isRValueReference; this.takesVarargs= takesVarargs; } @@ -52,17 +56,20 @@ return o.isSameType(this); if (o instanceof ICPPFunctionType) { ICPPFunctionType ft = (ICPPFunctionType) o; - if (isConst() != ft.isConst() || isVolatile() != ft.isVolatile() || takesVarArgs() != ft.takesVarArgs()) { + if (isConst() != ft.isConst() || isVolatile() != ft.isVolatile() + || hasRefQualifier() != ft.hasRefQualifier() + || isRValueReference() != ft.isRValueReference() + || takesVarArgs() != ft.takesVarArgs()) { return false; } IType[] fps; fps = ft.getParameterTypes(); - //constructors & destructors have null return type + // Constructors & destructors have null return type. if ((returnType == null) ^ (ft.getReturnType() == null)) return false; - if (returnType != null && ! returnType.isSameType(ft.getReturnType())) + if (returnType != null && !returnType.isSameType(ft.getReturnType())) return false; if (parameters.length == fps.length) { @@ -72,7 +79,7 @@ } } else { if (!SemanticUtil.isEmptyParameterList(parameters) - || !SemanticUtil.isEmptyParameterList(fps)) { + || !SemanticUtil.isEmptyParameterList(fps)) { return false; } } @@ -81,17 +88,11 @@ return false; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IFunctionType#getReturnType() - */ @Override public IType getReturnType() { return returnType; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IFunctionType#getParameterTypes() - */ @Override public IType[] getParameterTypes() { return parameters; @@ -125,6 +126,16 @@ } @Override + public boolean hasRefQualifier() { + return hasRefQualifier; + } + + @Override + public boolean isRValueReference() { + return isRValueReference; + } + + @Override public boolean takesVarArgs() { return takesVarargs; } @@ -137,9 +148,11 @@ @Override public void marshal(ITypeMarshalBuffer buffer) throws CoreException { short firstBytes= ITypeMarshalBuffer.FUNCTION_TYPE; - if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1; - if (takesVarArgs()) firstBytes |= ITypeMarshalBuffer.FLAG2; - if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG3; + if (isConst) firstBytes |= ITypeMarshalBuffer.FLAG1; + if (takesVarargs) firstBytes |= ITypeMarshalBuffer.FLAG2; + if (isVolatile) firstBytes |= ITypeMarshalBuffer.FLAG3; + if (hasRefQualifier) firstBytes |= ITypeMarshalBuffer.FLAG4; + if (isRValueReference) firstBytes |= ITypeMarshalBuffer.FLAG5; buffer.putShort(firstBytes); buffer.putInt(parameters.length); @@ -160,6 +173,8 @@ return new CPPFunctionType(rt, pars, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0, // const (firstBytes & ITypeMarshalBuffer.FLAG3) != 0, // volatile + (firstBytes & ITypeMarshalBuffer.FLAG5) != 0, // has ref-qualifier + (firstBytes & ITypeMarshalBuffer.FLAG4) != 0, // rvalue reference (firstBytes & ITypeMarshalBuffer.FLAG2) != 0); // takes varargs } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -81,7 +81,7 @@ private void initUsingDirectives() { if (fUsingDirectives == null) { - fUsingDirectives= new ArrayList(1); + fUsingDirectives= new ArrayList<>(1); // Insert a using directive for every inline namespace found in the index. for (ICPPInternalNamespaceScope inline : getIndexInlineNamespaces()) { if (!(inline instanceof CPPNamespaceScope)) { @@ -107,7 +107,7 @@ } public IScope findNamespaceScope(IIndexScope scope) { - final ArrayList parentChain = new ArrayList(); + final ArrayList parentChain = new ArrayList<>(); for (IBinding binding= scope.getScopeBinding(); binding != null; binding= binding.getOwner()) { parentChain.add(binding); } @@ -260,7 +260,7 @@ populateCache(); Set result= null; if (fInlineNamespaceDefinitions != null) { - result= new HashSet(fInlineNamespaceDefinitions.size()); + result= new HashSet<>(fInlineNamespaceDefinitions.size()); for (ICPPASTNamespaceDefinition nsdef : fInlineNamespaceDefinitions) { final IScope scope = nsdef.getScope(); if (scope instanceof ICPPInternalNamespaceScope) { @@ -271,7 +271,7 @@ for (ICPPInternalNamespaceScope inline : getIndexInlineNamespaces()) { if (result == null) - result = new HashSet(); + result = new HashSet<>(); result.add(inline); } @@ -284,7 +284,7 @@ private ICPPInternalNamespaceScope[] getIndexInlineNamespaces() { IASTTranslationUnit tu= getPhysicalNode().getTranslationUnit(); if (tu instanceof CPPASTTranslationUnit) { - CPPASTTranslationUnit cpptu= (CPPASTTranslationUnit) tu; + CPPASTTranslationUnit ast= (CPPASTTranslationUnit) tu; IIndex index= tu.getIndex(); if (index != null) { IScope[] inlineScopes= null; @@ -301,12 +301,10 @@ if (inlineScopes != null) { List result= null; for (IScope scope : inlineScopes) { - if (scope instanceof IIndexScope) { - scope= cpptu.mapToASTScope((IIndexScope) scope); - } + scope= ast.mapToASTScope(scope); if (scope instanceof ICPPInternalNamespaceScope) { if (result == null) { - result= new ArrayList(); + result= new ArrayList<>(); } result.add((ICPPInternalNamespaceScope) scope); } @@ -325,7 +323,7 @@ */ public void addInlineNamespace(ICPPASTNamespaceDefinition nsDef) { if (fInlineNamespaceDefinitions == null) { - fInlineNamespaceDefinitions= new ArrayList(); + fInlineNamespaceDefinitions= new ArrayList<>(); } fInlineNamespaceDefinitions.add(nsDef); } @@ -342,7 +340,7 @@ } } - Set result= new HashSet(); + Set result= new HashSet<>(); result.add(nsScope); addInlineNamespaces(nsScope, result); return result.toArray(new ICPPNamespaceScope[result.size()]); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java 2015-02-11 19:19:10.000000000 +0000 @@ -499,12 +499,12 @@ } @Override - public IASTName newName() { + public ICPPASTName newName() { return new CPPASTName(); } @Override - public IASTName newName(char[] name) { + public ICPPASTName newName(char[] name) { return new CPPASTName(name); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java 2015-02-11 19:19:10.000000000 +0000 @@ -35,7 +35,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; -import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.core.runtime.PlatformObject; @@ -246,7 +245,7 @@ public IValue getDefaultValue() { IASTInitializer init = getInitializer(); if (init != null) { - return SemanticUtil.getValueOfInitializer(init, getType(), Value.MAX_RECURSION_DEPTH); + return SemanticUtil.getValueOfInitializer(init, getType()); } return null; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java 2015-02-11 19:19:10.000000000 +0000 @@ -44,25 +44,16 @@ return false; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IQualifierType#isConst() - */ @Override public boolean isConst() { return isConst; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IQualifierType#isVolatile() - */ @Override public boolean isVolatile() { return isVolatile; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IQualifierType#getType() - */ @Override public IType getType() { return type; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -17,7 +17,6 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IName; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -78,7 +77,7 @@ } @Override - public IScope getParent() throws DOMException { + public IScope getParent() { return CPPVisitor.getContainingNonTemplateScope(physicalNode); } @@ -226,7 +225,7 @@ public IBinding[] getBindingsInAST(ScopeLookupData lookup) { populateCache(); final char[] c = lookup.getLookupKey(); - IBinding[] result = null; + IBinding[] result = IBinding.EMPTY_BINDING_ARRAY; Object obj = null; if (lookup.isPrefixLookup()) { @@ -258,7 +257,7 @@ result = addCandidate(obj, lookup, result); } } - return ArrayUtil.trim(IBinding.class, result); + return ArrayUtil.trim(result); } private IBinding[] addCandidate(Object candidate, ScopeLookupData lookup, IBinding[] result) { @@ -288,7 +287,9 @@ binding= (IBinding) candidate; } - return ArrayUtil.append(IBinding.class, result, binding); + if (binding != null) + result = ArrayUtil.append(result, binding); + return result; } @Override diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2015 Wind River Systems, 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: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -49,7 +50,6 @@ * scopes that can be reopened, i.e. namespaces. */ public class CPPScopeMapper { - /** * Used for implicit inline directives for inline namespaces found in the index. */ @@ -118,6 +118,7 @@ public IBinding[] getBindings(ScopeLookupData lookup) { return fScope.getBindings(lookup); } + @Override public IScope getParent() throws DOMException { IScope parent= fScope.getParent(); @@ -140,7 +141,7 @@ private void initUsingDirectives() { if (fUsingDirectives == null) { - fUsingDirectives= new ArrayList(1); + fUsingDirectives= new ArrayList<>(1); // Insert a using directive for every inline namespace for (ICPPInternalNamespaceScope inline: getInlineNamespaces()) { fUsingDirectives.add(new InlineNamespaceDirective(this, inline)); @@ -175,12 +176,19 @@ public ICPPInternalNamespaceScope[] getInlineNamespaces() { // Obtain the inline namespaces from the index and map them to the ast ICPPNamespaceScope[] pre = fScope.getInlineNamespaces(); + if (pre.length == 0) + return ICPPInternalNamespaceScope.EMPTY_NAMESPACE_SCOPE_ARRAY; ICPPInternalNamespaceScope[] result= new ICPPInternalNamespaceScope[pre.length]; for (int i = 0; i < result.length; i++) { result[i]= (ICPPInternalNamespaceScope) mapToASTScope((IIndexScope) pre[i]); } return result; } + + @Override + public String toString() { + return fScope.toString(); + } } /** @@ -213,6 +221,11 @@ public int getPointOfDeclaration() { return fOffset; } + + @Override + public String toString() { + return fDirective.toString(); + } } /** @@ -247,13 +260,12 @@ } } - private final HashMap fMappedScopes= new HashMap(); - private final HashMap fNamespaceWrappers= new HashMap(); - private final Map> fPerName= new HashMap>(); + private final HashMap fMappedScopes= new HashMap<>(); + private final HashMap fNamespaceWrappers= new HashMap<>(); + private final Map> fPerName= new HashMap<>(); private final CPPASTTranslationUnit fTu; protected CharArrayMap fClasses; - public CPPScopeMapper(CPPASTTranslationUnit tu) { fTu= tu; } @@ -303,7 +315,7 @@ private String getReverseQualifiedName(IScope scope) throws DOMException { final CPPNamespaceScope tuscope = fTu.getScope(); - if (scope == tuscope || scope == null) { + if (scope == tuscope || scope == null || scope.getKind() == EScopeKind.eGlobal) { return ""; //$NON-NLS-1$ } StringBuilder buf= new StringBuilder(); @@ -312,7 +324,7 @@ buf.append(scopeName.getSimpleID()); } scope= scope.getParent(); - while (scope != null && scope != tuscope) { + while (scope.getKind() != EScopeKind.eGlobal && scope != tuscope) { buf.append(':'); scopeName= scope.getScopeName(); if (scopeName != null) { @@ -327,7 +339,7 @@ * Maps namespace scopes from the index back into the AST. */ public IScope mapToASTScope(IIndexScope scope) { - if (scope == null) { + if (scope.getKind() == EScopeKind.eGlobal) { return fTu.getScope(); } if (scope instanceof ICPPNamespaceScope) { @@ -385,7 +397,7 @@ } if (fClasses == null) { - fClasses= new CharArrayMap(); + fClasses= new CharArrayMap<>(); fTu.accept(new Visitor()); } IASTName[] names= fClasses.get(type.getNameCharArray()); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java 2015-02-11 19:19:10.000000000 +0000 @@ -14,7 +14,6 @@ import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; @@ -30,7 +29,6 @@ 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.ICPPClassTemplate; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; @@ -52,13 +50,11 @@ public CPPTemplateProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); } + @Override public ICPPTemplateParameter[] getTemplateParameters() { return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY; } - public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException { - throw new DOMException(this); - } } protected IASTName[] declarations; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java 2015-02-11 19:19:10.000000000 +0000 @@ -93,7 +93,7 @@ if (d == null) return null; - IValue val= Value.create(d, Value.MAX_RECURSION_DEPTH); + IValue val= Value.create(d); IType t= getType(); return new CPPTemplateNonTypeArgument(val, t); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java 2015-02-11 19:19:10.000000000 +0000 @@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -96,10 +95,6 @@ return templateParameter; } - public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException { - return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY; - } - @Override public IType getDefault() { IASTName[] nds = getDeclarations(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownField.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownField.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownField.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownField.java 2015-02-11 19:19:10.000000000 +0000 @@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; -import org.eclipse.cdt.internal.core.dom.parser.ProblemType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeOfUnknownMember; /** * Represents a reference to a field, which cannot be resolved because the owner is @@ -78,7 +78,7 @@ @Override public IType getType() { - return ProblemType.UNKNOWN_FOR_EXPRESSION; + return new TypeOfUnknownMember(this); } @Override diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java 2015-02-11 19:19:10.000000000 +0000 @@ -67,6 +67,10 @@ @Override public ICPPFunctionType getType() { + // TODO(nathanridge): We'd like to return a TypeOfUnknownMember here, + // but that doesn't implement ICPPFuncionType. We'll probably have + // to write an implementation of ICPPFunctionType that stores the + // CPPUnknownMethod and resolves it upon instantiation. return FUNCTION_TYPE; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownTypeScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownTypeScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownTypeScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownTypeScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -32,9 +32,9 @@ import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; /** - * Models the scope represented by an unknown type (e.g.: typeof(template type parameter)). Used within - * the context of templates, only. - * For safe usage in index bindings, all fields need to be final or used in a thread-safe manner otherwise. + * Models the scope represented by an unknown type (e.g.: typeof(template type parameter)). + * Used within the context of templates, only. For safe usage in index bindings, all fields need + * to be final or used in a thread-safe manner otherwise. */ public class CPPUnknownTypeScope implements ICPPInternalUnknownScope { private final IASTName fName; @@ -111,8 +111,8 @@ } if (!type) { if (parent instanceof ICPPASTBaseSpecifier || - parent instanceof ICPPASTConstructorChainInitializer) { - type= true; + parent instanceof ICPPASTConstructorChainInitializer) { + type= true; } else if (parent instanceof ICPPASTNamedTypeSpecifier) { ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) parent; type= nts.isTypename(); @@ -123,7 +123,7 @@ } if (!type && parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) { - function= true; + function= true; } } } @@ -158,11 +158,11 @@ } IASTName lookupName= lookup.getLookupName(); if (lookupName != null) - return new IBinding[] {getBinding(lookupName, lookup.isResolve(), lookup.getIncludedFiles())}; + return new IBinding[] { getBinding(lookupName, lookup.isResolve(), lookup.getIncludedFiles()) }; // When dealing with dependent expressions we always create an unknown class. That is because // unknown objects are not used within the expressions, they are attached to names only. - return new IBinding[] {getOrCreateBinding(lookup.getLookupKey(), 0)}; + return new IBinding[] { getOrCreateBinding(lookup.getLookupKey(), 0) }; } @Override @@ -176,7 +176,7 @@ protected IBinding getOrCreateBinding(final char[] name, int idx) { if (map == null) - map = new CharArrayObjectMap(2); + map = new CharArrayObjectMap<>(2); IBinding[] o = map.get(name); if (o == null) { @@ -204,7 +204,7 @@ @Override public void addBinding(IBinding binding) { - // do nothing, this is part of template magic and not a normal scope + // Do nothing, this is part of template magic and not a normal scope. } @Override diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDirective.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDirective.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDirective.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUsingDirective.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2015 Wind River Systems, 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: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -26,7 +27,6 @@ * Represents a using-directive found in the AST. */ public class CPPUsingDirective implements ICPPUsingDirective { - private IASTName fNamespaceName; /** @@ -43,9 +43,6 @@ fNamespaceName= nsdef.getName(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective#getNamespaceScope() - */ @Override public ICPPNamespaceScope getNominatedScope() throws DOMException { IBinding binding= fNamespaceName.resolveBinding(); @@ -55,18 +52,12 @@ return null; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective#getPointOfDeclaration() - */ @Override public int getPointOfDeclaration() { final ASTNode astNode = (ASTNode) fNamespaceName; return astNode.getOffset() + astNode.getLength(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective#getContainingScope() - */ @Override public IScope getContainingScope() { return CPPVisitor.getContainingScope(fNamespaceName); @@ -74,6 +65,6 @@ @Override public String toString() { - return fNamespaceName.toString(); + return "using namespace " + fNamespaceName.toString(); //$NON-NLS-1$ } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java 2015-02-11 19:19:10.000000000 +0000 @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; @@ -34,20 +37,30 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; -import org.eclipse.cdt.internal.core.dom.parser.IInternalVariable; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.core.runtime.PlatformObject; -public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInternalBinding, IInternalVariable { +public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInternalBinding { private IASTName fDefinition; private IASTName fDeclarations[]; private IType fType; private boolean fAllResolved; + /** + * The set of CPPVariable objects for which initial value computation is in progress on each thread. + * This is used to guard against recursion during initial value computation. + */ + private static final ThreadLocal> fInitialValueInProgress = new ThreadLocal>() { + @Override + protected Set initialValue() { + return new HashSet<>(); + } + }; + public CPPVariable(IASTName name) { - boolean isDef = name == null ? false : name.isDefinition(); + boolean isDef = name != null && name.isDefinition(); if (name instanceof ICPPASTQualifiedName) { name = name.getLastName(); } @@ -145,7 +158,7 @@ IASTNode node = n.getParent(); if (node instanceof IASTDeclarator) { IType t= CPPVisitor.createType((IASTDeclarator) node); - if (t instanceof IArrayType && ((IArrayType) t).getSize() == null) { + if (t instanceof IArrayType && !((IArrayType) t).hasSize()) { if (firstCandidate == null) { firstCandidate= (IArrayType) t; } @@ -306,34 +319,37 @@ @Override public IValue getInitialValue() { - return getInitialValue(Value.MAX_RECURSION_DEPTH); - } - - @Override - public IValue getInitialValue(int maxDepth) { - if (fDefinition != null) { - final IValue val= getInitialValue(fDefinition, maxDepth); - if (val != null) - return val; + Set recursionProtectionSet = fInitialValueInProgress.get(); + if (!recursionProtectionSet.add(this)) { + return Value.UNKNOWN; } - if (fDeclarations != null) { - for (IASTName decl : fDeclarations) { - if (decl == null) - break; - final IValue val= getInitialValue(decl, maxDepth); + try { + if (fDefinition != null) { + final IValue val= getInitialValue(fDefinition); if (val != null) return val; } - } + if (fDeclarations != null) { + for (IASTName decl : fDeclarations) { + if (decl == null) + break; + final IValue val= getInitialValue(decl); + if (val != null) + return val; + } + } + } finally { + recursionProtectionSet.remove(this); + } return null; } - private IValue getInitialValue(IASTName name, int maxDepth) { + private IValue getInitialValue(IASTName name) { IASTDeclarator dtor= findDeclarator(name); if (dtor != null) { IASTInitializer init= dtor.getInitializer(); if (init != null) { - return SemanticUtil.getValueOfInitializer(init, getType(), maxDepth); + return SemanticUtil.getValueOfInitializer(init, getType()); } } return null; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 2015-02-11 19:19:10.000000000 +0000 @@ -19,9 +19,10 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; @@ -74,6 +75,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTClassVirtSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; @@ -91,13 +93,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression.CaptureDefault; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTClassVirtSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName; @@ -144,6 +146,7 @@ import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.core.parser.IToken.ContextSensitiveTokenType; import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.util.ArrayUtil; @@ -188,6 +191,8 @@ private final ICPPNodeFactory nodeFactory; private TemplateIdStrategy fTemplateParameterListStrategy; + + private Map fContextSensitiveTokens; public GNUCPPSourceParser(IScanner scanner, ParserMode mode, IParserLogService log, ICPPParserExtensionConfiguration config) { @@ -214,8 +219,25 @@ this.index= index; this.nodeFactory = CPPNodeFactory.getDefault(); scanner.setSplitShiftROperator(true); + fContextSensitiveTokens = createContextSensitiveTokenMap(config); } - + + private Map createContextSensitiveTokenMap( + ICPPParserExtensionConfiguration config) { + Map result = new HashMap(); + result.put(Keywords.OVERRIDE, ContextSensitiveTokenType.OVERRIDE); + result.put(Keywords.FINAL, ContextSensitiveTokenType.FINAL); + result.putAll(config.getAdditionalContextSensitiveKeywords()); + return result; + } + + private ContextSensitiveTokenType getContextSensitiveType(IToken token) { + if (!(token.getType() == IToken.tIDENTIFIER)) { + return null; + } + return fContextSensitiveTokens.get(new String(token.getCharImage())); + } + @Override protected IASTName identifier() throws EndOfFileException, BacktrackException { switch (LT(1)) { @@ -304,7 +326,7 @@ if (!haveName || destructorOffset >= 0 || keywordTemplate) { throwBacktrack(LA(1)); } - nameSpec= (ICPPASTName) nodeFactory.newName(CharArrayUtils.EMPTY); + nameSpec= nodeFactory.newName(CharArrayUtils.EMPTY); if (qname != null) { addNameSpecifier(qname, nameSpec); } @@ -571,6 +593,7 @@ case IToken.t_new: case IToken.t_delete: case IToken.t_sizeof: + case IToken.t_alignof: case IGCCToken.t___alignof__: return NO_TEMPLATE_ID; @@ -1382,6 +1405,7 @@ } return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), IASTTypeIdExpression.op_sizeof, IASTUnaryExpression.op_sizeof, ctx, strat); + case IToken.t_alignof: case IGCCToken.t___alignof__: return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), IASTTypeIdExpression.op_alignof, IASTUnaryExpression.op_alignOf, ctx, strat); @@ -3639,16 +3663,14 @@ throws EndOfFileException, BacktrackException { while (true) { IToken token = LAcatchEOF(1); - if (token.getType() != IToken.tIDENTIFIER) - break; - char[] tokenImage = token.getCharImage(); - if (Arrays.equals(Keywords.cOVERRIDE, tokenImage)) { + ContextSensitiveTokenType contextSensitiveType = getContextSensitiveType(token); + if (contextSensitiveType == ContextSensitiveTokenType.OVERRIDE) { consume(); ICPPASTVirtSpecifier spec = nodeFactory.newVirtSpecifier( ICPPASTVirtSpecifier.SpecifierKind.Override); setRange(spec, token.getOffset(), token.getOffset() + token.getLength()); typeRelevantDtor.addVirtSpecifier(spec); - } else if (Arrays.equals(Keywords.cFINAL, tokenImage)) { + } else if (contextSensitiveType == ContextSensitiveTokenType.FINAL) { consume(); ICPPASTVirtSpecifier spec = nodeFactory.newVirtSpecifier( ICPPASTVirtSpecifier.SpecifierKind.Final); @@ -4224,7 +4246,7 @@ endOffset= consume().getEndOffset(); } } else { - cvloop: while(true) { + cvloop: while (true) { switch (LT(1)) { case IToken.t_const: fc.setConst(true); @@ -4240,6 +4262,20 @@ } } + // ref-qualifiers + switch (LT(1)) { + case IToken.tAMPER: + fc.setRefQualifier(RefQualifier.LVALUE); + endOffset= consume().getEndOffset(); + break; + case IToken.tAND: + fc.setRefQualifier(RefQualifier.RVALUE); + endOffset= consume().getEndOffset(); + break; + default: + break; + } + // throws clause if (LT(1) == IToken.t_throw) { fc.setEmptyExceptionSpecification(); @@ -4474,8 +4510,8 @@ */ private void classVirtSpecifier(ICPPASTCompositeTypeSpecifier astClassSpecifier) throws EndOfFileException, BacktrackException { IToken token = LA(); - char[] tokenImage = token.getCharImage(); - if (token.getType() == IToken.tIDENTIFIER && Arrays.equals(Keywords.cFINAL, tokenImage)){ + ContextSensitiveTokenType contextSensitiveType = getContextSensitiveType(token); + if (contextSensitiveType == ContextSensitiveTokenType.FINAL) { consume(); ICPPASTClassVirtSpecifier spec = nodeFactory.newClassVirtSpecifier( ICPPASTClassVirtSpecifier.SpecifierKind.Final); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalTemplateDeclaration.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalTemplateDeclaration.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalTemplateDeclaration.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalTemplateDeclaration.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -18,7 +18,6 @@ * and the names of the nested declaration. */ public interface ICPPASTInternalTemplateDeclaration extends ICPPASTTemplateDeclaration { - /** * Returns whether this template declaration is associated with the last name of * the possibly qualified name of the enclosing declaration. If this template declaration diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java 2015-02-11 19:19:10.000000000 +0000 @@ -17,8 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionParameterMap; @@ -83,12 +83,12 @@ * @return a fully or partially instantiated evaluation, or the original evaluation */ ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point); + ICPPTypeSpecialization within, int maxdepth, IASTNode point); /** * Keeps track of state during a constexpr evaluation. */ - class ConstexprEvaluationContext { + final class ConstexprEvaluationContext { /** * The maximum number of steps allowed in a single constexpr evaluation. * This is used to prevent a buggy constexpr function from causing the @@ -100,7 +100,7 @@ private IASTNode fPoint; /** - * Construct a ConstexprEvaluationContext for a new constexpr evaluation. + * Constructs a ConstexprEvaluationContext for a new constexpr evaluation. * @param point the point of instantiation, determines the scope for name lookups */ public ConstexprEvaluationContext(IASTNode point) { @@ -109,7 +109,8 @@ } /** - * Record a new step being performed in this constexpr evaluation. + * Records a new step being performed in this constexpr evaluation. + * * @return this constexpr evaluation */ public ConstexprEvaluationContext recordStep() { @@ -118,14 +119,14 @@ } /** - * Get the number of steps performed so far in the constexpr evaluation. + * Returns the number of steps performed so far in the constexpr evaluation. */ public int getStepsPerformed() { return fStepsPerformed; } /** - * Get the point of instantiation. + * Returns the point of instantiation. */ public IASTNode getPoint() { return fPoint; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalBinding.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalBinding.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalBinding.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalBinding.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -7,6 +7,7 @@ * * Contributors: * Andrew Niefer (IBM Corporation) - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -14,15 +15,22 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; /** - * Non API methods for cpp bindings. + * Non API methods for C++ bindings. */ public interface ICPPInternalBinding extends ICPPBinding { - + /** + * Returns the definition of the binding, or {@code null} if the binding doesn't have + * a definition. + */ IASTNode getDefinition(); - /** Implementors must keep the node with the lowest offset in declarations[0] */ + /** + * Returns an array of declarations or {@code null} if the binding has no declarations. + * Implementors must keep the node with the lowest offset in declarations[0]. + */ IASTNode[] getDeclarations(); void addDefinition(IASTNode node); + void addDeclaration(IASTNode node); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalEnumerator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalEnumerator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalEnumerator.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalEnumerator.java 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2014 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp; + +import org.eclipse.cdt.core.dom.ast.IEnumerator; +import org.eclipse.cdt.core.dom.ast.IType; + +/** + * Non API methods for C++ enumerators. + */ +public interface ICPPInternalEnumerator extends IEnumerator { + /** + * Returns the internal type of the enumerator. The enumerator has this type between the opening + * and the closing braces of the enumeration ([dcl.enum] 7.2-5). + * + * @param type the integral type of the enumerator's initializing value + */ + IType getInternalType(); +} diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalNamespaceScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalNamespaceScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalNamespaceScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalNamespaceScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2010, 2015 Wind River Systems, 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: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -16,6 +17,7 @@ * For namespace scopes from the AST or mapped index namespace scopes. */ public interface ICPPInternalNamespaceScope extends ICPPNamespaceScope { + public ICPPInternalNamespaceScope[] EMPTY_NAMESPACE_SCOPE_ARRAY = {}; /** * Returns the enclosing namespace set (7.3.1-9) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2013 Google, Inc and others. + * Copyright (c) 2009, 2014 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 @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; +import org.eclipse.cdt.core.dom.ast.IType; 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.ICPPClassScope; @@ -29,9 +30,11 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.parser.util.ArrayUtil; 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; /** * The context that determines access to private and protected class members. @@ -76,7 +79,8 @@ */ private boolean isUnqualifiedLookup; private ICPPClassType namingClass; // depends on the binding for which we check the access - private ICPPClassType firstCandidateForNamingClass; // the first candidate is independent of the binding for which we do the access-check + // The first candidate is independent of the binding for which we do the access-check. + private ICPPClassType firstCandidateForNamingClass; private DOMException initializationException; public AccessContext(IASTName name) { @@ -89,6 +93,9 @@ * @return true if the binding is accessible. */ public boolean isAccessible(IBinding binding) { + if (binding instanceof ICPPTemplateParameter) + return true; + int bindingVisibility; if (binding instanceof ICPPMember) { bindingVisibility = ((ICPPMember) binding).getVisibility(); @@ -97,7 +104,8 @@ binding = ((ICPPSpecialization) binding).getSpecializedBinding(); } if (binding instanceof ICPPClassTemplatePartialSpecialization) { - // A class template partial specialization inherits the visibility of its primary class template. + // A class template partial specialization inherits the visibility of its primary + // class template. binding = ((ICPPClassTemplatePartialSpecialization) binding).getPrimaryClassTemplate(); } if (binding instanceof ICPPAliasTemplateInstance) { @@ -230,6 +238,9 @@ if (bases != null) { for (ICPPBase base : bases) { IBinding baseClass = base.getBaseClass(); + if (baseClass instanceof ICPPDeferredClassInstance) { + baseClass = ((ICPPDeferredClassInstance) baseClass).getTemplateDefinition(); + } if (!(baseClass instanceof ICPPClassType)) { continue; } @@ -248,9 +259,16 @@ LookupData data = new LookupData(name); isUnqualifiedLookup= !data.qualified; - ICPPScope scope= CPPSemantics.getLookupScope(name); + ICPPScope scope = CPPSemantics.getLookupScope(name); while (scope != null && !(scope instanceof ICPPClassScope)) { - scope = CPPSemantics.getParentScope(scope, data.getTranslationUnit()); + if (scope instanceof ICPPInternalUnknownScope) { + IType scopeType = ((ICPPInternalUnknownScope) scope).getScopeType(); + if (scopeType instanceof ICPPDeferredClassInstance) { + return ((ICPPDeferredClassInstance) scopeType).getClassTemplate(); + } + } else { + scope = CPPSemantics.getParentScope(scope, data.getTranslationUnit()); + } } if (scope instanceof ICPPClassScope) { return ((ICPPClassScope) scope).getClassType(); @@ -280,6 +298,9 @@ if (maxdepth > 0) { for (ICPPBase cppBase : ClassTypeHelper.getBases(derived, point)) { IBinding base= cppBase.getBaseClass(); + if (base instanceof ICPPSpecialization) { + base = ((ICPPSpecialization) base).getSpecializedBinding(); + } if (base instanceof ICPPClassType) { ICPPClassType tbase= (ICPPClassType) base; if (tbase.isSameType(target)) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java 2015-02-11 19:19:10.000000000 +0000 @@ -41,10 +41,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; /** - * Helper class for performing the base class lookup. First a directed graph without loops is computed - * to represent the base class hierarchy up to those bases for which the lookup finds matches. Next, from - * these leaves we search for virtual bases that are hidden. With this information the matches are extracted - * from the graph. + * Helper class for performing the base class lookup. First a directed graph without loops is + * computed to represent the base class hierarchy up to those bases for which the lookup finds + * matches. Next, from these leaves we search for virtual bases that are hidden. With this + * information the matches are extracted from the graph. */ class BaseClassLookup { public static void lookupInBaseClasses(LookupData data, ICPPClassScope classScope) { @@ -55,7 +55,7 @@ if (classType == null) return; - final HashMap infoMap = new HashMap(); + final HashMap infoMap = new HashMap<>(); BaseClassLookup rootInfo= lookupInBaseClass(data, null, false, classType, infoMap, 0); if (data.contentAssist) { rootInfo.collectResultForContentAssist(data); @@ -108,7 +108,7 @@ return; if (fChildren.isEmpty()) { - fChildren= new ArrayList(); + fChildren= new ArrayList<>(); fVirtual= new BitSet(); } fVirtual.set(fChildren.size(), virtual); @@ -156,7 +156,7 @@ if (baseClassScope != null) { BaseClassLookup info= infoMap.get(baseClassScope); if (info != null) { - // avoid loops + // Avoid loops. if (info.getResult() == null) { data.problem = new ProblemBinding(null, IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE, root.getNameCharArray()); @@ -204,12 +204,12 @@ } } } catch (DOMException e) { - // continue the lookup + // Continue the lookup. } } - // There is no result in the baseClass itself or we do content assist, we have to examine its - // base-classes + // There is no result in the baseClass itself or we do content assist, we have to examine + // its base classes. ICPPClassType baseClass= result.getClassType(); if (baseClass != null) { ICPPBase[] grandBases= ClassTypeHelper.getBases(baseClass, data.getLookupPoint()); @@ -217,9 +217,9 @@ HashSet grandBaseBindings= null; BitSet selectedBases= null; if (grandBases.length > 1) { - grandBaseBindings= new HashSet(); + grandBaseBindings= new HashSet<>(); - // if we have reachable bases, then ignore the others + // If we have reachable bases, then ignore the others. selectedBases = selectPreferredBases(data, grandBases); } for (int i = 0; i < grandBases.length; i++) { @@ -229,7 +229,7 @@ IBinding grandBaseBinding = grandBase.getBaseClass(); if (!(grandBaseBinding instanceof ICPPClassType)) { - // 14.6.2.3 scope is not examined + // 14.6.2.3 scope is not examined. if (grandBaseBinding instanceof ICPPUnknownBinding) { if (data.skippedScope == null) data.skippedScope= root; @@ -247,7 +247,7 @@ final IScope grandBaseScope= grandBaseClass.getCompositeScope(); if (grandBaseScope == null || grandBaseScope instanceof ICPPInternalUnknownScope) { - // 14.6.2.3 scope is not examined + // 14.6.2.3 scope is not examined. if (data.skippedScope == null) data.skippedScope= root; continue; @@ -335,7 +335,7 @@ } baseInfo.propagateHiddenAsVirtual(); } else { - // mark to catch recursions + // Mark to catch recursions. baseInfo= new BaseClassLookup(baseClass, fLookupPoint); infoMap.put(baseScope, baseInfo); baseInfo.hideVirtualBases(infoMap, depth); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java 2015-02-11 19:19:10.000000000 +0000 @@ -342,7 +342,25 @@ * 13.3.3.1.5 List-initialization sequence [over.ics.list] */ static Cost listInitializationSequence(EvalInitList arg, IType target, UDCMode udc, boolean isDirect, IASTNode point) throws DOMException { + Cost result = listInitializationSequenceHelper(arg, target, udc, isDirect, point); + result.setListInitializationTarget(target); + return result; + } + + static Cost listInitializationSequenceHelper(EvalInitList arg, IType target, UDCMode udc, boolean isDirect, IASTNode point) throws DOMException { IType listType= getInitListType(target); + if (listType == null && target instanceof IArrayType) { + Long arraySize = ((IArrayType) target).getSize().numericalValue(); + if (arraySize != null) { + IType elementType = ((IArrayType) target).getType(); + // TODO(nathanridge): If there are fewer initializer clauses than the array size, + // then the element type is required to be default-constructible. + if (arg.getClauses().length <= arraySize.longValue()) { + listType = elementType; + } + } + } + if (listType != null) { ICPPEvaluation[] clauses = arg.getClauses(); Cost worstCost= new Cost(arg.getTypeOrFunctionSet(point), target, Rank.IDENTITY); @@ -583,6 +601,11 @@ bestCost.setRank(Rank.NO_MATCH); } } + // This cost came from listInitializationSequence() with an std::initializer_list + // type as the list initialization target. From the point of view of the caller, + // however, the target is the class type, not std::initializer_list, so update it + // accordingly. + bestCost.setListInitializationTarget(t); return bestCost; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Cost.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Cost.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Cost.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Cost.java 2015-02-11 19:19:10.000000000 +0000 @@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IType; @@ -93,8 +94,15 @@ private boolean fImpliedObject; private ICPPFunction fUserDefinedConversion; private ReferenceBinding fReferenceBinding; - private boolean fCouldNarrow; + + // For a list-initialization sequence, 'target' is not always the original + // target type. Specifically, for an original target type of + // std::initializer_list or array of T, 'target' will be T, but we need + // to know the original target as well so we store it here. + // This will be null iff. this is not a list-initialization sequence. + private IType fListInitializationTarget; + private ICPPFunction fSelectedFunction; // For targeted functions public Cost(IType s, IType t, Rank rank) { @@ -192,6 +200,35 @@ if (cmp != 0) return cmp; + // [over.ics.rank] p3.3: + // List-initialization sequence L1 is a better conversion sequence than + // list-initialization sequence L2 if + if (fListInitializationTarget != null && other.fListInitializationTarget != null) { + // - L1 converts to std::initializer_list for some X and L2 does not, + // or if not that, + IType initListType = Conversions.getInitListType(fListInitializationTarget); + IType otherInitListType = Conversions.getInitListType(other.fListInitializationTarget); + if (initListType != null && otherInitListType == null) { + return -1; + } else if (initListType == null && otherInitListType != null) { + return 1; + } + + // - L1 converts to type "array of N1 T", L2 converts to type "array of + // N2 T", and N1 is smaller than N2 + if (fListInitializationTarget instanceof IArrayType && other.fListInitializationTarget instanceof IArrayType) { + IArrayType arrayType = (IArrayType) fListInitializationTarget; + IArrayType otherArrayType = (IArrayType) other.fListInitializationTarget; + if (arrayType.getType().isSameType(otherArrayType.getType())) { + Long size = arrayType.getSize().numericalValue(); + Long otherSize = otherArrayType.getSize().numericalValue(); + if (size != null && otherSize != null) { + return size.compareTo(otherSize); + } + } + } + } + // rank is equal if (rank == Rank.USER_DEFINED_CONVERSION) { // 13.3.3.1.10 @@ -233,6 +270,7 @@ if ((other.fQualificationAdjustments & qdiff) == 0) return 1; } + return 0; } @@ -352,4 +390,8 @@ public void setImpliedObject() { fImpliedObject= true; } + + public void setListInitializationTarget(IType target) { + fListInitializationTarget = target; + } } \ No newline at end of file diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java 2015-02-11 19:19:10.000000000 +0000 @@ -17,9 +17,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.core.runtime.CoreException; @@ -108,7 +108,7 @@ */ protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions( ICPPEvaluation[] subexpressions, ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPEvaluation[] result = subexpressions; int resultShift = 0; for (int i = 0; i < subexpressions.length; i++) { @@ -141,9 +141,9 @@ newEval = origEval.instantiate(tpMap, packOffset, within, maxdepth, point); } - if (result != subexpressions) + if (result != subexpressions) { result[i + resultShift] = newEval; - else if (newEval != origEval) { + } else if (newEval != origEval) { assert resultShift == 0; result = new ICPPEvaluation[subexpressions.length]; System.arraycopy(subexpressions, 0, result, 0, i); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java 2015-02-11 19:19:10.000000000 +0000 @@ -16,10 +16,10 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.core.runtime.CoreException; @@ -47,7 +47,7 @@ } protected static IBinding resolveUnknown(ICPPUnknownBinding unknown, ICPPTemplateParameterMap tpMap, - int packOffset, ICPPClassSpecialization within, IASTNode point) { + int packOffset, ICPPTypeSpecialization within, IASTNode point) { try { return CPPTemplates.resolveUnknown(unknown, tpMap, packOffset, within, point); } catch (DOMException e) { @@ -57,7 +57,7 @@ } protected static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args, - ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) { + ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point) { try { return CPPTemplates.instantiateArguments(args, tpMap, packOffset, within, point, false); } catch (DOMException e) { @@ -66,8 +66,8 @@ return args; } - protected static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + protected static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, + int packOffset, ICPPTypeSpecialization within, int maxdepth, IASTNode point) { try { return CPPTemplates.instantiateBinding(binding, tpMap, packOffset, within, maxdepth, point); } catch (DOMException e) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java 2015-02-11 19:19:10.000000000 +0000 @@ -475,14 +475,10 @@ // binding. final ASTNodeProperty namePropertyInParent = name.getPropertyInParent(); if (binding == null && data.skippedScope != null) { - if (data.hasFunctionArguments()) { - binding= new CPPDeferredFunction(data.skippedScope, name.getSimpleID(), null); + if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) { + binding= new CPPUnknownMemberClass(data.skippedScope, name.getSimpleID()); } else { - if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) { - binding= new CPPUnknownMemberClass(data.skippedScope, name.getSimpleID()); - } else { - binding= new CPPUnknownMethod(data.skippedScope, name.getSimpleID()); - } + binding= new CPPUnknownMethod(data.skippedScope, name.getSimpleID()); } } @@ -817,8 +813,8 @@ if (binding == null) return null; IScope scope = binding.getScope(); - if (scope instanceof IIndexScope) { - scope= tu.mapToASTScope((IIndexScope) scope); + if (tu != null) { + scope= tu.mapToASTScope(scope); } while (scope != null && !(scope instanceof ICPPNamespaceScope)) { scope = getParentScope(scope, tu); @@ -986,7 +982,7 @@ } while (nextScope != null || nextTmplScope != null) { - // when the non-template scope is no longer contained within the first template scope, + // When the non-template scope is no longer contained within the first template scope, // we use the template scope for the next iteration. boolean useTemplScope= false; if (nextTmplScope != null) { @@ -1000,8 +996,8 @@ } ICPPScope scope= useTemplScope ? nextTmplScope : nextScope; CPPASTTranslationUnit tu = data.getTranslationUnit(); - if (scope instanceof IIndexScope && tu != null) { - scope= (ICPPScope) tu.mapToASTScope(((IIndexScope) scope)); + if (tu != null) { + scope= (ICPPScope) tu.mapToASTScope((scope)); } if (!data.usingDirectivesOnly && !(data.ignoreMembers && scope instanceof ICPPClassScope)) { @@ -1009,14 +1005,14 @@ // Nominate using-directives found in this block or namespace. if (scope instanceof ICPPNamespaceScope) { - final ICPPNamespaceScope blockScope= (ICPPNamespaceScope) scope; + final ICPPNamespaceScope namespaceScope= (ICPPNamespaceScope) scope; - if (data.qualified && blockScope.getKind() != EScopeKind.eLocal) { - lookupInlineNamespaces(data, blockScope); + if (data.qualified && namespaceScope.getKind() != EScopeKind.eLocal) { + lookupInlineNamespaces(data, namespaceScope); } if (data.contentAssist || !data.hasResults() || !data.qualified) { // Nominate namespaces - nominateNamespaces(data, blockScope); + nominateNamespaces(data, namespaceScope); } } } @@ -1359,13 +1355,13 @@ static ICPPScope getParentScope(IScope scope, ICPPASTTranslationUnit unit) throws DOMException { IScope parentScope= scope.getParent(); - // the index cannot return the translation unit as parent scope + // The index cannot return the translation unit as parent scope. if (unit instanceof CPPASTTranslationUnit) { if (parentScope == null && (scope instanceof IIndexScope || scope instanceof ICPPClassSpecializationScope)) { parentScope = unit.getScope(); - } else if (parentScope instanceof IIndexScope) { - parentScope = ((CPPASTTranslationUnit) unit).mapToASTScope((IIndexScope) parentScope); + } else { + parentScope = ((CPPASTTranslationUnit) unit).mapToASTScope(parentScope); } } return (ICPPScope) parentScope; @@ -1381,8 +1377,8 @@ ICPPUsingDirective directive, Set handled) throws DOMException { ICPPNamespaceScope nominated= directive.getNominatedScope(); CPPASTTranslationUnit tu= data.getTranslationUnit(); - if (nominated instanceof IIndexScope && tu != null) { - nominated= (ICPPNamespaceScope) tu.mapToASTScope((IIndexScope) nominated); + if (tu != null) { + nominated= (ICPPNamespaceScope) tu.mapToASTScope(nominated); } if (nominated == null || data.visited.containsKey(nominated) || (handled != null && !handled.add(nominated))) { return; @@ -1906,7 +1902,13 @@ while (dtor.getParent() instanceof IASTDeclarator) dtor = (IASTDeclarator) dtor.getParent(); IASTInitializer init = dtor.getInitializer(); - if (init != null) + // [basic.scope.pdecl]/p9: The point of declaration for a template parameter + // is immediately after its complete template-parameter. + // Note: can't just check "dtor.getParent() instanceof ICPPASTTemplateParameter" + // because function parameter declarations implement ICPPASTTemplateParameter too. + boolean isTemplateParameter = dtor.getParent() instanceof ICPPASTTemplateParameter + && dtor.getParent().getPropertyInParent() == ICPPASTTemplateDeclaration.PARAMETER; + if (init != null && !isTemplateParameter) pointOfDecl = ((ASTNode) init).getOffset() - 1; else pointOfDecl = ((ASTNode) dtor).getOffset() + ((ASTNode) dtor).getLength(); @@ -1926,6 +1928,15 @@ } else if (prop == ICPPASTNamespaceAlias.ALIAS_NAME) { nd = (ASTNode) nd.getParent(); pointOfDecl = nd.getOffset() + nd.getLength(); + } else if (prop == ICPPASTSimpleTypeTemplateParameter.PARAMETER_NAME + || prop == ICPPASTTemplatedTypeTemplateParameter.PARAMETER_NAME) { + // [basic.scope.pdecl]/p9: The point of declaration for a template parameter + // is immediately after its complete template-parameter. + // Type and template template parameters are handled here; + // non-type template parameters are handled in the DECLARATOR_NAME + // case above. + nd = (ASTNode) nd.getParent(); + pointOfDecl = nd.getOffset() + nd.getLength(); } else { pointOfDecl = nd.getOffset() + nd.getLength(); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java 2015-02-11 19:19:10.000000000 +0000 @@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumerator; +import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; @@ -52,6 +53,7 @@ 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.IVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; @@ -99,6 +101,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; 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.ICPPTypeSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; import org.eclipse.cdt.core.index.IIndexBinding; @@ -127,7 +130,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumerationSpecialization; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumeratorSpecialization; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFieldSpecialization; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization; @@ -168,6 +170,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.Context; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMode; +import org.eclipse.cdt.internal.core.index.IIndexType; /** * Collection of static methods to perform template instantiation, member specialization and @@ -418,6 +421,17 @@ ICPPTemplateInstance result = ((ICPPInstanceCache) template).getInstance(args); if (forDefinition && result instanceof IIndexBinding) return null; + if (result != null) { + // Don't use the cached instance if its argument is an index type and the requested + // argument is an AST type. Despite identical signatures the types may be different. + ICPPTemplateArgument[] instanceArgs = result.getTemplateArguments(); + for (int i = 0; i < args.length; i++) { + if (!(args[i].getTypeValue() instanceof IIndexType) && + (instanceArgs[i].getTypeValue() instanceof IIndexType)) { + return null; + } + } + } return result; } return null; @@ -704,6 +718,9 @@ ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) template; ICPPTemplateArgument[] args = createTemplateArgumentArray(id); args = addDefaultArguments(aliasTemplate, args, id); + if (args == null) { + return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray()); + } ICPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args); IType aliasedType = aliasTemplate.getType(); IBinding owner = template.getOwner(); @@ -716,6 +733,9 @@ ICPPTemplateArgument[] args = createTemplateArgumentArray(id); ICPPAliasTemplate aliasTemplate = aliasTemplateInstance.getTemplateDefinition(); args = addDefaultArguments(aliasTemplate, args, id); + if (args == null) { + return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray()); + } ICPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args); IType aliasedType = aliasTemplateInstance.getType(); IBinding owner = aliasTemplateInstance.getOwner(); @@ -849,7 +869,7 @@ } public static ICPPParameter[] specializeParameters(ICPPParameter[] parameters, ICPPFunction functionSpec, - ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, int maxdepth, + ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, int maxdepth, IASTNode point) { if (parameters.length == 0) { return parameters; @@ -864,6 +884,7 @@ if (i < parameters.length) { par = parameters[i]; } // else reuse last parameter (which should be a pack) + @SuppressWarnings("null") IValue defaultValue = par.getDefaultValue(); IValue specializedValue = CPPTemplates.instantiateValue(defaultValue, tpMap, packOffset, within, maxdepth, point); @@ -951,22 +972,7 @@ IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point); spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type); } else if (decl instanceof ICPPEnumeration) { - ICPPClassSpecialization within = getSpecializationContext(owner); - ICPPEnumeration enumeration = (ICPPEnumeration) decl; - IType fixedType = instantiateType(enumeration.getFixedType(), tpMap, -1, within, point); - CPPEnumerationSpecialization specializedEnumeration = - new CPPEnumerationSpecialization(enumeration, owner, tpMap, fixedType); - IEnumerator[] enumerators = enumeration.getEnumerators(); - IEnumerator[] specializedEnumerators = new IEnumerator[enumerators.length]; - for (int i = 0; i < enumerators.length; ++i) { - IEnumerator enumerator = enumerators[i]; - IValue specializedValue = - instantiateValue(enumerator.getValue(), tpMap, -1, within, Value.MAX_RECURSION_DEPTH, point); - specializedEnumerators[i] = - new CPPEnumeratorSpecialization(enumerator, specializedEnumeration, tpMap, specializedValue); - } - specializedEnumeration.setEnumerators(specializedEnumerators); - spec = specializedEnumeration; + spec = CPPEnumerationSpecialization.createInstance((ICPPEnumeration) decl, owner, tpMap, point); } else if (decl instanceof IEnumerator) { IEnumerator enumerator = (IEnumerator) decl; ICPPEnumeration enumeration = (ICPPEnumeration) enumerator.getOwner(); @@ -975,7 +981,7 @@ spec = enumSpec.specializeEnumerator(enumerator); } else if (decl instanceof ICPPUsingDeclaration) { IBinding[] delegates= ((ICPPUsingDeclaration) decl).getDelegates(); - List result= new ArrayList(); + List result= new ArrayList<>(); ICPPClassSpecialization within = getSpecializationContext(owner); for (IBinding delegate : delegates) { try { @@ -1001,10 +1007,10 @@ return spec; } - private static ICPPClassSpecialization getSpecializationContext(IBinding owner) { - if (!(owner instanceof ICPPClassSpecialization)) + public static ICPPClassSpecialization getSpecializationContext(IBinding owner) { + ICPPClassSpecialization within = getContextClassSpecialization(owner); + if (within == null) return null; - ICPPClassSpecialization within= (ICPPClassSpecialization) owner; ICPPClassType orig = within.getSpecializedBinding(); while (true) { IBinding o1 = within.getOwner(); @@ -1019,8 +1025,16 @@ } } + protected static ICPPClassSpecialization getContextClassSpecialization(IBinding owner) { + if (owner instanceof ICPPEnumerationSpecialization) + owner = owner.getOwner(); + if (owner instanceof ICPPClassSpecialization) + return (ICPPClassSpecialization) owner; + return null; + } + public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { if (value == null) return null; ICPPEvaluation evaluation = value.getEvaluation(); @@ -1138,7 +1152,7 @@ * @return an array containing instantiated types. */ public static IType[] instantiateTypes(IType[] types, ICPPTemplateParameterMap tpMap, - int packOffset, ICPPClassSpecialization within, IASTNode point) { + int packOffset, ICPPTypeSpecialization within, IASTNode point) { if (types == null) return null; @@ -1190,7 +1204,7 @@ * arguments. */ public static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args, - ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, + ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point, boolean strict) throws DOMException { // Don't create a new array until it's really needed. @@ -1254,7 +1268,7 @@ * Instantiates an argument */ static ICPPTemplateArgument instantiateArgument(ICPPTemplateArgument arg, - ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) { + ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point) { if (arg == null) return null; if (arg.isNonTypeValue()) { @@ -1273,7 +1287,7 @@ } private static CPPTemplateParameterMap instantiateArgumentMap(ICPPTemplateParameterMap orig, ICPPTemplateParameterMap tpMap, - int packOffset, ICPPClassSpecialization within, IASTNode point) { + int packOffset, ICPPTypeSpecialization within, IASTNode point) { final Integer[] positions = orig.getAllParameterPositions(); CPPTemplateParameterMap newMap= new CPPTemplateParameterMap(positions.length); for (Integer key : positions) { @@ -1302,7 +1316,7 @@ * The context is used to replace templates with their specialization, where appropriate. */ public static IType instantiateType(IType type, ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, IASTNode point) { + ICPPTypeSpecialization within, IASTNode point) { try { if (tpMap == null) return type; @@ -1325,7 +1339,8 @@ params[i]= CPPVisitor.adjustParameterType(p, true); } } - return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs()); + return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), + ft.hasRefQualifier(), ft.isRValueReference(), ft.takesVarArgs()); } if (type instanceof ICPPTemplateParameter) { @@ -1335,34 +1350,50 @@ if (type instanceof ICPPUnknownBinding) { if (type instanceof TypeOfDependentExpression) { ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation(); - ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point); + ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within, + Value.MAX_RECURSION_DEPTH, point); if (instantiated != eval) return instantiated.getTypeOrFunctionSet(point); } else { - IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset, within, point); + IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset, + within, point); if (binding instanceof IType) return (IType) binding; return type; } } + + if (type instanceof TypeOfUnknownMember) { + IBinding binding = resolveUnknown(((TypeOfUnknownMember) type).getUnknownMember(), tpMap, packOffset, within, point); + if (binding instanceof IType) { + return (IType) binding; + } else if (binding instanceof IVariable) { + return ((IVariable) binding).getType(); + } else if (binding instanceof IFunction) { + return ((IFunction) binding).getType(); + } + return type; + } if (within != null && type instanceof IBinding) { IType unwound= getNestedType(type, TDEF); - if (unwound instanceof ICPPClassType && unwound.isSameType(within.getSpecializedBinding())) { - // Convert (partial) class-templates (specializations) to the more specialized version. - if (within instanceof ICPPClassTemplate || !(unwound instanceof ICPPClassTemplate)) - return within; + ICPPClassSpecialization withinClass = getContextClassSpecialization(within); + if (unwound instanceof ICPPClassType && unwound.isSameType(withinClass.getSpecializedBinding())) { + // Convert (partial) class-templates (specializations) to the more specialized + // version. + if (withinClass instanceof ICPPClassTemplate || !(unwound instanceof ICPPClassTemplate)) + return withinClass; } IBinding typeAsBinding= (IBinding) type; IBinding owner= typeAsBinding.getOwner(); if (owner instanceof IType) { final IType ownerAsType = getNestedType((IType) owner, TDEF); Object newOwner= owner; - if (ownerAsType instanceof ICPPClassType && ownerAsType.isSameType(within.getSpecializedBinding())) { - // Convert (partial) class-templates (specializations) that are used as owner of - // another binding, to the more specialized version. - newOwner= within; + if (ownerAsType instanceof ICPPClassType && ownerAsType.isSameType(withinClass.getSpecializedBinding())) { + // Convert (partial) class-templates (specializations) that are used as + // owner of another binding, to the more specialized version. + newOwner= withinClass; } else { newOwner= instantiateType(ownerAsType, tpMap, packOffset, within, point); } @@ -1378,9 +1409,11 @@ final IBinding origClass = classInstance.getSpecializedBinding(); if (origClass instanceof ICPPClassType) { ICPPTemplateArgument[] args = classInstance.getTemplateArguments(); - ICPPTemplateArgument[] newArgs = instantiateArguments(args, tpMap, packOffset, within, point, false); + ICPPTemplateArgument[] newArgs = instantiateArguments(args, tpMap, packOffset, + within, point, false); if (newArgs != args) { - CPPTemplateParameterMap tparMap = instantiateArgumentMap(classInstance.getTemplateParameterMap(), tpMap, packOffset, within, point); + CPPTemplateParameterMap tparMap = instantiateArgumentMap(classInstance.getTemplateParameterMap(), + tpMap, packOffset, within, point); return new CPPClassInstance((ICPPClassType) origClass, classInstance.getOwner(), tparMap, args); } } @@ -1483,15 +1516,14 @@ } public static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) throws DOMException { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) throws DOMException { if (binding instanceof ICPPClassTemplate) { binding = createDeferredInstance((ICPPClassTemplate) binding); } if (binding instanceof ICPPUnknownBinding) { return resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point); - } else if (binding instanceof IEnumerator - || binding instanceof ICPPMethod + } else if (binding instanceof ICPPMethod || binding instanceof ICPPField || binding instanceof ICPPEnumeration || binding instanceof ICPPClassType) { @@ -1499,20 +1531,24 @@ if (!(owner instanceof ICPPSpecialization)) { owner = instantiateBinding(owner, tpMap, packOffset, within, maxdepth, point); } - if (binding instanceof IEnumerator) { - if (owner instanceof ICPPEnumerationSpecialization) { - return ((ICPPEnumerationSpecialization) owner).specializeEnumerator((IEnumerator) binding); - } - } else { - if (owner instanceof ICPPClassSpecialization) { - return ((ICPPClassSpecialization) owner).specializeMember(binding, point); - } + if (owner instanceof ICPPClassSpecialization) { + return ((ICPPClassSpecialization) owner).specializeMember(binding, point); + } + } else if (binding instanceof IEnumerator) { + IBinding owner = binding.getOwner(); + if (within instanceof ICPPEnumerationSpecialization && within.getSpecializedBinding().equals(owner)) { + owner = within; + } else if (!(owner instanceof ICPPSpecialization)) { + owner = instantiateBinding(owner, tpMap, packOffset, within, maxdepth, point); + } + if (owner instanceof ICPPEnumerationSpecialization) { + return ((ICPPEnumerationSpecialization) owner).specializeEnumerator((IEnumerator) binding); } } else if (binding instanceof ICPPFunctionInstance) { // TODO(nathanridge): - // Maybe we should introduce an ICPPDeferredFunctionInstance and have things that can return - // a dependent ICPPFunctionInstance (like instantiateForAddressOfFunction) return that when - // appropriate? + // Maybe we should introduce an ICPPDeferredFunctionInstance and have things that can + // return a dependent ICPPFunctionInstance (like instantiateForAddressOfFunction) + // return that when appropriate? ICPPFunctionInstance origInstance = (ICPPFunctionInstance) binding; ICPPTemplateArgument[] origArgs = origInstance.getTemplateArguments(); ICPPTemplateArgument[] newArgs = instantiateArguments(origArgs, tpMap, packOffset, within, point, false); @@ -2227,10 +2263,11 @@ } } ICPPFunctionType originalType = function.getType(); - if (i == parameters.length) // no parameters with default arguments + if (i == parameters.length) // No parameters with default arguments. return originalType; return new CPPFunctionType(originalType.getReturnType(), ArrayUtil.trim(parameterTypes), - originalType.isConst(), originalType.isVolatile(), originalType.takesVarArgs()); + originalType.isConst(), originalType.isVolatile(), originalType.hasRefQualifier(), + originalType.isRValueReference(), originalType.takesVarArgs()); } private static int compareSpecialization(ICPPFunctionTemplate f1, ICPPFunctionTemplate f2, TypeSelection mode, IASTNode point) throws DOMException { @@ -2699,9 +2736,10 @@ * Attempts to (partially) resolve an unknown binding with the given arguments. */ public static IBinding resolveUnknown(ICPPUnknownBinding unknown, ICPPTemplateParameterMap tpMap, - int packOffset, ICPPClassSpecialization within, IASTNode point) throws DOMException { + int packOffset, ICPPTypeSpecialization within, IASTNode point) throws DOMException { if (unknown instanceof ICPPDeferredClassInstance) { - return resolveDeferredClassInstance((ICPPDeferredClassInstance) unknown, tpMap, packOffset, within, point); + return resolveDeferredClassInstance((ICPPDeferredClassInstance) unknown, tpMap, packOffset, + within, point); } if (unknown instanceof ICPPUnknownMember) { return resolveUnknownMember((ICPPUnknownMember) unknown, tpMap, packOffset, within, point); @@ -2720,7 +2758,7 @@ } private static IBinding resolveUnknownMember(ICPPUnknownMember unknown, ICPPTemplateParameterMap tpMap, - int packOffset, ICPPClassSpecialization within, IASTNode point) throws DOMException { + int packOffset, ICPPTypeSpecialization within, IASTNode point) throws DOMException { final IType ot0= unknown.getOwnerType(); if (ot0 == null) return unknown; @@ -2766,7 +2804,7 @@ } private static IBinding resolveDeferredClassInstance(ICPPDeferredClassInstance dci, - ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) { + ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point) { ICPPClassTemplate classTemplate = dci.getClassTemplate(); ICPPTemplateArgument[] arguments = dci.getTemplateArguments(); ICPPTemplateArgument[] newArgs; @@ -2844,7 +2882,7 @@ if (keys.length == 0) return ObjectMap.EMPTY_MAP; - List defs= new ArrayList(); + List defs= new ArrayList<>(); IBinding owner= b; while (owner != null) { if (owner instanceof ICPPTemplateDefinition) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java 2015-02-11 19:19:10.000000000 +0000 @@ -81,7 +81,6 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IBasicType; -import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; @@ -99,6 +98,7 @@ import org.eclipse.cdt.core.dom.ast.IValue; 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.ICPPASTCapture; 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; @@ -112,6 +112,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause; @@ -142,6 +143,7 @@ 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.ICPPASTWhileStatement; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; @@ -182,7 +184,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression; 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; @@ -225,18 +226,6 @@ * Collection of methods to extract information from a C++ translation unit. */ public class CPPVisitor extends ASTQueries { - public static final CPPBasicType SHORT_TYPE = new CPPBasicType(Kind.eInt, IBasicType.IS_SHORT); - public static final CPPBasicType INT_TYPE = new CPPBasicType(Kind.eInt, 0); - public static final CPPBasicType LONG_TYPE = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG); - public static final CPPBasicType LONG_LONG_TYPE = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG_LONG); - public static final CPPBasicType INT128_TYPE = new CPPBasicType(Kind.eInt128, 0); - - public static final CPPBasicType UNSIGNED_SHORT = new CPPBasicType(Kind.eInt, IBasicType.IS_SHORT | IBasicType.IS_UNSIGNED); - public static final CPPBasicType UNSIGNED_INT = new CPPBasicType(Kind.eInt, IBasicType.IS_UNSIGNED); - public static final CPPBasicType UNSIGNED_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED); - public static final CPPBasicType UNSIGNED_LONG_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG_LONG | IBasicType.IS_UNSIGNED); - public static final CPPBasicType UNSIGNED_INT128 = new CPPBasicType(Kind.eInt128, IBasicType.IS_UNSIGNED); - public static final String BEGIN_STR = "begin"; //$NON-NLS-1$ public static final char[] BEGIN = BEGIN_STR.toCharArray(); public static final char[] END = "end".toCharArray(); //$NON-NLS-1$ @@ -255,7 +244,7 @@ new ThreadLocal>() { @Override protected Set initialValue() { - return new HashSet(); + return new HashSet<>(); } }; @@ -265,6 +254,7 @@ if (parent instanceof IASTNamedTypeSpecifier || parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTConstructorChainInitializer || + parent instanceof ICPPASTCapture || name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME) { if (name.getLookupKey().length == 0) return null; @@ -283,7 +273,7 @@ binding = CPPSemantics.resolveBinding(name); if (parent instanceof IASTCompositeTypeSpecifier) { if (binding instanceof IIndexBinding) { - // Need to create an AST binding + // Need to create an AST binding. } else { ASTInternal.addDefinition(binding, parent); return binding; @@ -297,7 +287,7 @@ if (CPPTemplates.isClassTemplate(id)) return CPPSemantics.resolveBinding(name); - // function templates/instances/specializations must be resolved via the id + // Function templates/instances/specializations must be resolved via the id. id.resolveBinding(); return name.getBinding(); } @@ -478,6 +468,13 @@ } return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION); } + // [dcl.enum] 7.2-5 + // "The underlying type can be explicitly specified using enum-base; + // if not explicitly specified, the underlying type of a scoped + // enumeration type is int." + if (fixedType == null && specifier.isScoped()) { + fixedType = CPPBasicType.INT; + } return new CPPEnumeration(specifier, fixedType); } @@ -520,7 +517,7 @@ binding = CPPSemantics.resolveBinding(elabType.getName()); } if (binding instanceof IIndexBinding && binding instanceof ICPPClassType) { - binding= ((CPPASTTranslationUnit) elabType.getTranslationUnit()).mapToAST((ICPPClassType) binding, elabType); + binding= (ICPPClassType) SemanticUtil.mapToAST((ICPPClassType) binding, elabType); ASTInternal.addDeclaration(binding, elabType); } @@ -875,7 +872,7 @@ t2 = ((IVariable) binding).getType(); } if (t1 != null && t2 != null) { - if (t1.isSameType(t2) || isCompatibleArray(t1, t2) != null) { + if (areArraysOfTheSameElementType(t1, t2) || t1.isSameType(t2)) { ASTInternal.addDeclaration(binding, name); } else { binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION); @@ -1273,9 +1270,7 @@ boolean done= true; IScope scope= null; if (binding instanceof ICPPClassType) { - if (binding instanceof IIndexBinding && tu != null) { - binding= (((CPPASTTranslationUnit) tu)).mapToAST((ICPPClassType) binding, name); - } + binding= (ICPPClassType) SemanticUtil.mapToAST((ICPPClassType) binding, name); scope= ((ICPPClassType) binding).getCompositeScope(); } else if (binding instanceof ICPPNamespace) { scope= ((ICPPNamespace) binding).getNamespaceScope(); @@ -1440,7 +1435,7 @@ private void addProblem(IASTProblem problem) { if (fProblems == null) { - fProblems= new ArrayList(); + fProblems= new ArrayList<>(); } fProblems.add(problem); } @@ -1482,7 +1477,7 @@ shouldVisitNames = true; this.decls = new IASTName[DEFAULT_LIST_SIZE]; - final String bname= binding.getName(); + final String bname = binding.getName(); if (bname.length() > 0 && !bname.startsWith("operator")) { //$NON-NLS-1$ requiredName= bname.toCharArray(); } @@ -1495,6 +1490,7 @@ } else if (binding instanceof ICPPTemplateParameter) { kind = KIND_TEMPLATE_PARAMETER; } else if (binding instanceof ICompositeType || + binding instanceof ICPPAliasTemplate || binding instanceof ITypedef || binding instanceof IEnumeration) { kind = KIND_TYPE; @@ -1548,7 +1544,8 @@ case KIND_TYPE: case KIND_COMPOSITE: if (prop == IASTCompositeTypeSpecifier.TYPE_NAME || - prop == IASTEnumerationSpecifier.ENUMERATION_NAME || + prop == ICPPASTAliasDeclaration.ALIAS_NAME || + prop == IASTEnumerationSpecifier.ENUMERATION_NAME || prop == ICPPASTUsingDeclaration.NAME) { break; } else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) { @@ -1607,7 +1604,7 @@ if (areEquivalentBindings(nameBinding, binding, index)) { return true; } - // A using declaration is a declaration for the references of its delegates + // A using declaration is a declaration for the references of its delegates. if (nameBinding instanceof ICPPUsingDeclaration) { if (ArrayUtil.contains(((ICPPUsingDeclaration) nameBinding).getDelegates(), binding)) { return true; @@ -1631,8 +1628,9 @@ return true; } if ((binding1 instanceof IIndexBinding) != (binding2 instanceof IIndexBinding) && index != null) { - // Even though we know one of them is an index binding, we need to adapt both because they might not come from an - // index with the same number of fragments. So one of them could be a composite binding and the other one not. + // Even though we know one of them is an index binding, we need to adapt both because + // they might not come from an index with the same number of fragments. So one of them + // could be a composite binding and the other one not. binding1 = index.adaptBinding(binding1); binding2 = index.adaptBinding(binding2); @@ -1750,6 +1748,7 @@ prop == IASTNamedTypeSpecifier.NAME || prop == ICPPASTConstructorChainInitializer.MEMBER_ID || prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT || + prop == ICPPASTCapture.IDENTIFIER || prop == IASTImplicitNameOwner.IMPLICIT_NAME) { break; } @@ -1830,7 +1829,7 @@ pTypes[i] = pt; } - return new CPPFunctionType(returnType, pTypes, isConst, isVolatile, false); + return new CPPFunctionType(returnType, pTypes, isConst, isVolatile, false, false, false); } /** @@ -1869,7 +1868,9 @@ returnType = getPointerTypes(returnType, fnDtor); } - CPPFunctionType type = new CPPFunctionType(returnType, pTypes, fnDtor.isConst(), fnDtor.isVolatile(), + RefQualifier refQualifier = fnDtor.getRefQualifier(); + CPPFunctionType type = new CPPFunctionType(returnType, pTypes, fnDtor.isConst(), + fnDtor.isVolatile(), refQualifier != null, refQualifier == RefQualifier.RVALUE, fnDtor.takesVarArgs()); final IASTDeclarator nested = fnDtor.getNestedDeclarator(); if (nested != null) { @@ -2034,8 +2035,9 @@ } IType type = createType(declSpec); + type = makeConstIfConstexpr(type, declSpec, declarator); type = createType(type, declarator); - + // C++ specification 8.3.4.3 and 8.5.1.4 IASTNode initClause= declarator.getInitializer(); if (initClause instanceof IASTEqualsInitializer) { @@ -2238,9 +2240,22 @@ private static IType decorateType(IType type, IASTDeclSpecifier declSpec, IASTDeclarator declarator) { type = qualifyType(type, declSpec); + type = makeConstIfConstexpr(type, declSpec, declarator); return createType(type, declarator); } + private static IType makeConstIfConstexpr(IType type, IASTDeclSpecifier declSpec, IASTDeclarator declarator) { + // [dcl.constexpr] p9: constexpr on a variable makes it const + if (!(declarator instanceof IASTFunctionDeclarator)) { + if (declSpec instanceof ICPPASTDeclSpecifier) { + if (((ICPPASTDeclSpecifier) declSpec).isConstexpr()) { + return SemanticUtil.constQualify(type); + } + } + } + return type; + } + private static IType qualifyType(IType type, IASTDeclSpecifier declSpec) { return SemanticUtil.addQualifiers(type, declSpec.isConst(), declSpec.isVolatile(), declSpec.isRestrict()); } @@ -2349,7 +2364,7 @@ public static IType getPointerDiffType(final IASTNode point) { IType t= getStdType(point, PTRDIFF_T); - return t != null ? t : LONG_TYPE; + return t != null ? t : CPPBasicType.LONG; } private static IType getStdType(final IASTNode node, char[] name) { @@ -2375,12 +2390,12 @@ public static IType get_type_info(IASTNode point) { IType t= getStdType(point, TYPE_INFO); - return t != null ? t : INT_TYPE; + return t != null ? t : CPPBasicType.INT; } public static IType get_SIZE_T(IASTNode sizeofExpr) { IType t= getStdType(sizeofExpr, SIZE_T); - return t != null ? t : UNSIGNED_LONG; + return t != null ? t : CPPBasicType.UNSIGNED_LONG; } public static ICPPClassTemplate get_initializer_list(IASTNode node) { @@ -2552,7 +2567,7 @@ break; IBinding binding = segments[i].resolveBinding(); if (binding instanceof IIndexBinding && binding instanceof ICPPClassType) { - binding = ((CPPASTTranslationUnit) name.getTranslationUnit()).mapToAST((ICPPClassType) binding, name); + binding = (ICPPClassType) SemanticUtil.mapToAST((ICPPClassType) binding, name); } return bindingToOwner(binding); } @@ -2613,36 +2628,33 @@ boolean isFriend= isFriendDeclaration(node); - // Search for enclosing binding - IASTName name= null; - node= node.getParent(); - for (; node != null; node= node.getParent()) { + // Search for enclosing binding. + for (node= node.getParent(); node != null; node= node.getParent()) { if (node instanceof IASTFunctionDefinition) { - if (!allowFunction) - return null; - - IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); - if (dtor != null) { - name= dtor.getName(); + if (allowFunction) { + IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); + if (dtor != null) { + return dtor.getName(); + } } - break; + return null; } if (node instanceof IASTCompositeTypeSpecifier) { if (isFriend || isNonSimpleElabDecl) continue; - name= ((IASTCompositeTypeSpecifier) node).getName(); - break; + return ((IASTCompositeTypeSpecifier) node).getName(); } if (node instanceof ICPPASTNamespaceDefinition) { - name= ((ICPPASTNamespaceDefinition) node).getName(); - break; + return ((ICPPASTNamespaceDefinition) node).getName(); } if (node instanceof ICPPASTEnumerationSpecifier) { - name= ((ICPPASTEnumerationSpecifier) node).getName(); - break; + return ((ICPPASTEnumerationSpecifier) node).getName(); + } + if (node instanceof ICPPASTLambdaExpression) { + return ((ICPPASTLambdaExpression) node).getClosureTypeName(); } } - return name; + return null; } public static boolean doesNotSpecifyType(IASTDeclSpecifier declspec) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java 2015-02-11 19:19:10.000000000 +0000 @@ -51,12 +51,12 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -356,7 +356,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPEvaluation arg1 = fArg1.instantiate(tpMap, packOffset, within, maxdepth, point); ICPPEvaluation arg2 = fArg2.instantiate(tpMap, packOffset, within, maxdepth, point); if (arg1 == fArg1 && arg2 == fArg2) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java 2015-02-11 19:19:10.000000000 +0000 @@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -132,7 +132,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { IType type1 = CPPTemplates.instantiateType(fType1, tpMap, packOffset, within, point); IType type2 = CPPTemplates.instantiateType(fType2, tpMap, packOffset, within, point); if (type1 == fType1 && type2 == fType2) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java 2015-02-11 19:19:10.000000000 +0000 @@ -28,7 +28,6 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IVariable; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType; @@ -38,8 +37,8 @@ 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.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.core.index.IIndexBinding; -import org.eclipse.cdt.internal.core.dom.parser.IInternalVariable; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -317,9 +316,7 @@ IValue value= null; // No need to call getBinding() since a function parameter never has an initial value. - if (fBinding instanceof IInternalVariable) { - value= ((IInternalVariable) fBinding).getInitialValue(Value.MAX_RECURSION_DEPTH); - } else if (fBinding instanceof IVariable) { + if (fBinding instanceof IVariable) { value= ((IVariable) fBinding).getInitialValue(); } else if (fBinding instanceof IEnumerator) { value= ((IEnumerator) fBinding).getValue(); @@ -377,7 +374,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { IBinding origBinding = getBinding(); if (origBinding instanceof ICPPTemplateNonTypeParameter) { if (tpMap != null) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java 2015-02-11 19:19:10.000000000 +0000 @@ -20,9 +20,9 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.Value; @@ -185,7 +185,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPEvaluation[] args = fArguments; for (int i = 0; i < fArguments.length; i++) { ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java 2015-02-11 19:19:10.000000000 +0000 @@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; @@ -100,7 +100,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPEvaluation delegate = fDelegate.instantiate(tpMap, packOffset, within, maxdepth, point); if (delegate == fDelegate) return this; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java 2015-02-11 19:19:10.000000000 +0000 @@ -28,10 +28,10 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -342,7 +342,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPEvaluation condition = fCondition.instantiate(tpMap, packOffset, within, maxdepth, point); ICPPEvaluation positive = fPositive == null ? null : fPositive.instantiate(tpMap, packOffset, within, maxdepth, point); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java 2015-02-11 19:19:10.000000000 +0000 @@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -165,7 +165,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { IType type = CPPTemplates.instantiateType(fType, tpMap, packOffset, within, point); IValue value = CPPTemplates.instantiateValue(fValue, tpMap, packOffset, within, maxdepth, point); if (type == fType && value == fValue) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java 2015-02-11 19:19:10.000000000 +0000 @@ -28,11 +28,11 @@ import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -191,7 +191,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap, packOffset, within, maxdepth, point); if (args == fArguments) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java 2015-02-11 19:19:10.000000000 +0000 @@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; @@ -228,10 +229,10 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { if (fFunctionSet == null) return this; - + ICPPTemplateArgument[] originalArguments = fFunctionSet.getTemplateArguments(); ICPPTemplateArgument[] arguments = originalArguments; if (originalArguments != null) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others. + * Copyright (c) 2012, 2014 Wind River Systems, 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 @@ -20,6 +20,7 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; @@ -37,7 +38,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; 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.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.ICPPConstructor; @@ -48,11 +48,13 @@ 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.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalEnumerator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.core.runtime.CoreException; @@ -253,14 +255,13 @@ IType type= ((IEnumerator) binding).getType(); if (type instanceof ICPPEnumeration) { ICPPEnumeration enumType= (ICPPEnumeration) type; - if (enumType.asScope() == CPPVisitor.getContainingScope(expr)) { - // C++0x: 7.2-5 - type= enumType.getFixedType(); - if (type == null) { - // This is a simplification, the actual type is determined - // - in an implementation dependent manner - by the value - // of the enumerator. - type= CPPSemantics.INT_TYPE; + // [dcl.enum] 7.2-5 + if (isInsideEnum(expr, enumType)) { + if (binding instanceof ICPPInternalEnumerator) { + type = enumType.getFixedType(); + if (type == null) { + type = ((ICPPInternalEnumerator) binding).getInternalType(); + } } return new EvalBinding(binding, type, expr); } @@ -274,6 +275,17 @@ return EvalFixed.INCOMPLETE; } + /** + * Returns {@code true} if the given node is located inside the given enum. + */ + private static boolean isInsideEnum(IASTNode node, ICPPEnumeration enumBinding) { + IASTEnumerator enumeratorNode = CPPVisitor.findAncestorWithType(node, IASTEnumerator.class); + if (enumeratorNode == null) + return false; + IBinding enumerator = enumeratorNode.getName().getBinding(); + return enumerator != null && enumBinding == enumerator.getOwner(); + } + private static IType withinNonStaticMethod(IASTExpression expr) { IASTNode parent= expr.getParent(); while (parent != null && !(parent instanceof ICPPASTFunctionDefinition)) { @@ -306,7 +318,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPTemplateArgument[] templateArgs = fTemplateArgs; if (templateArgs != null) { templateArgs = instantiateArguments(templateArgs, tpMap, packOffset, within, point); @@ -323,10 +335,7 @@ tpMap, packOffset, within, point); } else if (nameOwner instanceof IType) { IType type = CPPTemplates.instantiateType((IType) nameOwner, tpMap, packOffset, within, point); - if (type instanceof IBinding) { - type = getNestedType(type, TDEF); - } - + type = getNestedType(type, TDEF | REF | CVTYPE); if (!(type instanceof IBinding)) return EvalFixed.INCOMPLETE; nameOwner = (IBinding) type; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java 2015-02-11 19:19:10.000000000 +0000 @@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.Value; @@ -109,7 +109,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPEvaluation[] clauses = instantiateCommaSeparatedSubexpressions(fClauses, tpMap, packOffset, within, maxdepth, point); if (clauses == fClauses) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java 2015-02-11 19:19:10.000000000 +0000 @@ -41,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -340,7 +341,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { IType ownerType = CPPTemplates.instantiateType(fOwnerType, tpMap, packOffset, within, point); if (ownerType == fOwnerType) return this; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalParameterPack.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalParameterPack.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalParameterPack.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalParameterPack.java 2015-02-11 19:19:10.000000000 +0000 @@ -15,8 +15,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -96,8 +96,9 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { - ICPPEvaluation expansionPattern = fExpansionPattern.instantiate(tpMap, packOffset, within, maxdepth, point); + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { + ICPPEvaluation expansionPattern = fExpansionPattern.instantiate(tpMap, packOffset, within, + maxdepth, point); if (expansionPattern == fExpansionPattern) return this; return new EvalParameterPack(expansionPattern, getTemplateDefinition()); @@ -106,7 +107,8 @@ @Override public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, ConstexprEvaluationContext context) { - ICPPEvaluation expansionPattern = fExpansionPattern.computeForFunctionCall(parameterMap, context.recordStep()); + ICPPEvaluation expansionPattern = fExpansionPattern.computeForFunctionCall(parameterMap, + context.recordStep()); if (expansionPattern == fExpansionPattern) return this; return new EvalParameterPack(expansionPattern, getTemplateDefinition()); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java 2015-02-11 19:19:10.000000000 +0000 @@ -22,11 +22,11 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.Value; @@ -215,7 +215,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPEvaluation[] args= instantiateCommaSeparatedSubexpressions(fArguments, tpMap, packOffset, within, maxdepth, point); IType type = CPPTemplates.instantiateType(fInputType, tpMap, packOffset, within, point); if (args == fArguments && type == fInputType) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java 2015-02-11 19:19:10.000000000 +0000 @@ -40,15 +40,17 @@ import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -57,6 +59,7 @@ import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArithmeticConversion; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClosureType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; @@ -239,17 +242,35 @@ case op_postFixDecr: case op_postFixIncr: return prvalueType(fArgument.getTypeOrFunctionSet(point)); - case op_minus: case op_plus: + return promoteType(fArgument.getTypeOrFunctionSet(point), true); + case op_minus: case op_tilde: - final IType t1 = prvalueType(fArgument.getTypeOrFunctionSet(point)); - final IType t2 = SemanticUtil.getNestedType(t1, TDEF); - final IType t3= CPPArithmeticConversion.promoteCppType(t2); - return (t3 == null || t3 == t2) ? t1 : t3; + return promoteType(fArgument.getTypeOrFunctionSet(point), false); } return fArgument.getTypeOrFunctionSet(point); } + private IType promoteType(IType type, boolean allowPointer) { + final IType t1 = prvalueType(type); + final IType t2 = SemanticUtil.getNestedType(t1, TDEF); + if (allowPointer) { + if (t2 instanceof CPPClosureType) { + ICPPMethod conversionOperator = ((CPPClosureType) t2).getConversionOperator(); + if (conversionOperator == null) + return ProblemType.UNKNOWN_FOR_EXPRESSION; + return new CPPPointerType(conversionOperator.getType().getReturnType()); + } + if (t2 instanceof IPointerType) { + return t1; + } + } + final IType t3= CPPArithmeticConversion.promoteCppType(t2); + if (t3 == null && !(t2 instanceof IBasicType)) + return ProblemType.UNKNOWN_FOR_EXPRESSION; + return (t3 == null || t3 == t2) ? t1 : t3; + } + @Override public IValue getValue(IASTNode point) { if (isValueDependent()) @@ -329,19 +350,20 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { ICPPEvaluation argument = fArgument.instantiate(tpMap, packOffset, within, maxdepth, point); - IBinding aoqn = fAddressOfQualifiedNameBinding; - if (aoqn instanceof ICPPUnknownBinding) { + IBinding binding = fAddressOfQualifiedNameBinding; + if (binding instanceof ICPPUnknownBinding) { try { - aoqn= CPPTemplates.resolveUnknown((ICPPUnknownBinding) aoqn, tpMap, packOffset, within, point); + binding= CPPTemplates.resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, + within, point); } catch (DOMException e) { } } - if (argument == fArgument && aoqn == fAddressOfQualifiedNameBinding) + if (argument == fArgument && binding == fAddressOfQualifiedNameBinding) return this; - return new EvalUnary(fOperator, argument, aoqn, getTemplateDefinition()); + return new EvalUnary(fOperator, argument, binding, getTemplateDefinition()); } @Override diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java 2015-02-11 19:19:10.000000000 +0000 @@ -42,8 +42,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; @@ -203,7 +203,7 @@ @Override public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, - ICPPClassSpecialization within, int maxdepth, IASTNode point) { + ICPPTypeSpecialization within, int maxdepth, IASTNode point) { if (fOperator == op_sizeofParameterPack) { int packSize = determinePackSize(tpMap); if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java 2015-02-11 19:19:10.000000000 +0000 @@ -484,15 +484,12 @@ } public IType[] getFunctionArgumentTypes() { - if (functionArgTypes == null) { - if (functionArgs != null) { - ICPPEvaluation[] exprs= functionArgs; - functionArgTypes= new IType[exprs.length]; - for (int i = 0; i < exprs.length; i++) { - ICPPEvaluation e = exprs[i]; - functionArgTypes[i]= getSimplifiedType(e.getTypeOrFunctionSet(getLookupPoint())); - } - } + if (functionArgTypes == null && functionArgs != null) { + functionArgTypes= new IType[functionArgs.length]; + for (int i = 0; i < functionArgs.length; i++) { + ICPPEvaluation e = functionArgs[i]; + functionArgTypes[i]= getSimplifiedType(e.getTypeOrFunctionSet(getLookupPoint())); + } } return functionArgTypes; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2014 IBM Corporation and others. + * Copyright (c) 2004, 2015 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 @@ -44,6 +44,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; @@ -67,6 +68,7 @@ import org.eclipse.cdt.core.parser.util.CharArraySet; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.ObjectSet; +import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit; @@ -355,7 +357,8 @@ if (ret == r && params == ps) { return type; } - return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs()); + return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), + ft.hasRefQualifier(), ft.isRValueReference(), ft.takesVarArgs()); } if (type instanceof ITypedef) { @@ -405,7 +408,7 @@ if (newNestedType == null) return type; - // Bug 249085 make sure not to add unnecessary qualifications + // Do not to add unnecessary qualifications (bug 24908). if (type instanceof IQualifierType) { IQualifierType qt= (IQualifierType) type; return addQualifiers(newNestedType, qt.isConst(), qt.isVolatile(), false); @@ -488,37 +491,62 @@ } } - public static IType mapToAST(IType type, IASTNode node) { - if (node == null) - return type; + public static IType mapToAST(IType type, IASTNode point) { + if (point != null && type instanceof IIndexBinding && type instanceof ICPPClassType) { + IASTTranslationUnit ast = point.getTranslationUnit(); + if (ast instanceof CPPASTTranslationUnit) { + return ((CPPASTTranslationUnit) ast).mapToAST((ICPPClassType) type, point); + } + } + return type; + } - if (type instanceof IFunctionType) { - final ICPPFunctionType ft = (ICPPFunctionType) type; - final IType r = ft.getReturnType(); - final IType ret = mapToAST(r, node); - if (ret == r) { - return type; + public static ICPPTemplateArgument[] mapToAST(ICPPTemplateArgument[] args, IASTNode point) { + if (point == null) + return args; + + // Don't create a new array until it's really needed. + ICPPTemplateArgument[] result = args; + for (int i = 0; i < args.length; i++) { + final ICPPTemplateArgument arg = args[i]; + ICPPTemplateArgument newArg = arg; + if (arg != null) { + newArg = mapToAST(arg, point); + if (result != args) { + result[i] = newArg; + } else if (arg != newArg) { + result = new ICPPTemplateArgument[args.length]; + if (i > 0) { + System.arraycopy(args, 0, result, 0, i); + } + result[i] = newArg; + } } - return new CPPFunctionType(ret, ft.getParameterTypes(), ft.isConst(), ft.isVolatile(), ft.takesVarArgs()); } - if (type instanceof ITypeContainer) { - final ITypeContainer tc = (ITypeContainer) type; - final IType nestedType= tc.getType(); - if (nestedType == null) - return type; + return result; + } - IType newType= mapToAST(nestedType, node); - if (newType != nestedType) { - return replaceNestedType(tc, newType); + public static ICPPTemplateArgument mapToAST(ICPPTemplateArgument arg, IASTNode point) { + IType type = arg.getTypeValue(); + if (type != null) { + IType mappedType = mapToAST(type, point); + IType originalType = arg.getOriginalTypeValue(); + IType mappedOriginalType = originalType == type ? mappedType : mapToAST(originalType, point); + if (mappedType != type || mappedOriginalType != originalType) { + return new CPPTemplateTypeArgument(mappedType, mappedOriginalType); } - return type; - } else if (type instanceof ICPPClassType && type instanceof IIndexBinding) { - IASTTranslationUnit tu = node.getTranslationUnit(); - if (tu instanceof CPPASTTranslationUnit) { - return ((CPPASTTranslationUnit) tu).mapToAST((ICPPClassType) type, node); + } + return arg; + } + + public static IScope mapToAST(IScope scope, IASTNode point) { + if (point != null) { + IASTTranslationUnit ast = point.getTranslationUnit(); + if (ast instanceof ASTTranslationUnit) { + return ((ASTTranslationUnit) ast).mapToASTScope(scope); } } - return type; + return scope; } public static IType[] getSimplifiedTypes(IType[] types) { @@ -711,13 +739,16 @@ clazz= (ICPPClassType) ((ICPPDeferredClassInstance) clazz).getSpecializedBinding(); } + // The base classes may have changed since the definition of clazz was indexed. + clazz = (ICPPClassType) mapToAST(clazz, point); + for (ICPPBase cppBase : ClassTypeHelper.getBases(clazz, point)) { IBinding base= cppBase.getBaseClass(); if (base instanceof IType && hashSet.add(base)) { IType tbase= (IType) base; if (tbase.isSameType(baseClass) || - (baseClass instanceof ICPPSpecialization && // allow some flexibility with templates - ((IType)((ICPPSpecialization) baseClass).getSpecializedBinding()).isSameType(tbase))) { + (baseClass instanceof ICPPSpecialization && // Allow some flexibility with templates. + ((IType) ((ICPPSpecialization) baseClass).getSpecializedBinding()).isSameType(tbase))) { return 1; } @@ -789,9 +820,8 @@ * * @param init the initializer's AST node * @param type the type of the variable - * @param maxDepth maximum recursion depth */ - public static IValue getValueOfInitializer(IASTInitializer init, IType type, int maxDepth) { + public static IValue getValueOfInitializer(IASTInitializer init, IType type) { IASTInitializerClause clause= null; if (init instanceof IASTEqualsInitializer) { clause= ((IASTEqualsInitializer) init).getInitializerClause(); @@ -813,7 +843,7 @@ } } if (clause instanceof IASTExpression) { - return Value.create((IASTExpression) clause, maxDepth); + return Value.create((IASTExpression) clause); } return Value.UNKNOWN; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfUnknownMember.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfUnknownMember.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfUnknownMember.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfUnknownMember.java 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2014 Nathan Ridge. + * 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: + * Nathan Ridge - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IType; +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.CPPUnknownMember; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType; +import org.eclipse.cdt.internal.core.index.IIndexFragment; +import org.eclipse.core.runtime.CoreException; + +/** + * Represents the type of an unknown member. + */ +public class TypeOfUnknownMember implements ICPPUnknownType, ISerializableType { + private final CPPUnknownMember fMember; + + public TypeOfUnknownMember(CPPUnknownMember member) { + fMember = member; + } + + public CPPUnknownMember getUnknownMember() { + return fMember; + } + + @Override + public boolean isSameType(IType type) { + return type instanceof TypeOfUnknownMember + && fMember == ((TypeOfUnknownMember) type).fMember; + } + + @Override + public void marshal(ITypeMarshalBuffer buffer) throws CoreException { + buffer.putShort(ITypeMarshalBuffer.UNKNOWN_MEMBER_TYPE); + fMember.marshal(buffer); + } + + public static IType unmarshal(IIndexFragment fragment, short firstBytes, ITypeMarshalBuffer buffer) throws CoreException { + short firstBytesForMember = buffer.getShort(); + if ((firstBytesForMember & ITypeMarshalBuffer.KIND_MASK) != ITypeMarshalBuffer.UNKNOWN_MEMBER) + throw new CoreException(CCorePlugin.createStatus("Expected an unknown memebr, first bytes=" + firstBytesForMember)); //$NON-NLS-1$; + return new TypeOfUnknownMember((CPPUnknownMember) CPPUnknownMember.unmarshal(fragment, firstBytesForMember, buffer)); + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + return null; + } + } +} diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeTraits.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeTraits.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeTraits.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeTraits.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Google, Inc and others. + * Copyright (c) 2012, 2014 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 @@ -30,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.SemanticQueries; import org.eclipse.cdt.internal.core.dom.parser.ArithmeticConversion; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnaryTypeTransformation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper.MethodKind; @@ -38,6 +39,19 @@ * A collection of static methods for determining type traits. */ public class TypeTraits { + private static final ICPPBasicType[] SIGNED_UNDERLYING_ENUM_TYPES = { + CPPBasicType.INT, + CPPBasicType.LONG, + CPPBasicType.LONG_LONG, + CPPBasicType.INT128 + }; + private static final ICPPBasicType[] UNSIGNED_UNDERLYING_ENUM_TYPES = { + CPPBasicType.UNSIGNED_INT, + CPPBasicType.UNSIGNED_LONG, + CPPBasicType.UNSIGNED_LONG_LONG, + CPPBasicType.UNSIGNED_INT128 + }; + private TypeTraits() {} /** @@ -165,20 +179,20 @@ } /** - * Returns true if and only if the given class has a trivial copy constructor. + * Returns {@code true} if and only if the given class has a trivial copy constructor. * A copy constructor is trivial if: *
    *
  • it is implicitly defined by the compiler, and
  • - *
  • isPolymorphic(classType) is false, and
  • + *
  • {@code isPolymorphic(classType)} is {@code false}, and
  • *
  • the class has no virtual base classes, and
  • *
  • every direct base class has trivial copy constructor, and
  • *
  • for every nonstatic data member that has class type or array of class type, that type * has trivial copy constructor.
  • *
- * Similar to std::tr1::has_trivial_copy. + * Similar to {@code std::tr1::has_trivial_copy}. * * @param classType the class to check - * @return true if the class has a trivial copy constructor + * @return {@code true} if the class has a trivial copy constructor */ public static boolean hasTrivialCopyCtor(ICPPClassType classType, IASTNode point) { if (getImplicitCopyCtor(classType, point) == null) @@ -193,7 +207,7 @@ if (!classType.isSameType(baseClass) && !hasTrivialCopyCtor(baseClass, point)) return false; } - for (ICPPField field : classType.getDeclaredFields()) { + for (ICPPField field : ClassTypeHelper.getDeclaredFields(classType, point)) { if (!field.isStatic()) { IType type = field.getType(); type = SemanticUtil.getNestedType(type, TDEF | CVTYPE | ARRAY); @@ -207,7 +221,7 @@ } /** - * Returns true if and only if the given class has a trivial default constructor. + * Returns {@code true} if and only if the given class has a trivial default constructor. * A default constructor is trivial if: *
    *
  • it is implicitly defined by the compiler, and
  • @@ -215,11 +229,11 @@ *
  • for every nonstatic data member that has class type or array of class type, that type * has trivial default constructor.
  • *
- * Similar to std::tr1::has_trivial_default_constructor. + * Similar to {@code std::tr1::has_trivial_default_constructor}. * * @param classType the class to check * @param point - * @return true if the class has a trivial default constructor + * @return {@code true} if the class has a trivial default constructor */ public static boolean hasTrivialDefaultConstructor(ICPPClassType classType, IASTNode point) { for (ICPPConstructor ctor : ClassTypeHelper.getConstructors(classType, point)) { @@ -244,7 +258,7 @@ } /** - * Returns true if and only if the given class has a trivial destructor. + * Returns {@code true} if and only if the given class has a trivial destructor. * A destructor is trivial if: *
    *
  • it is implicitly defined by the compiler, and
  • @@ -252,10 +266,10 @@ *
  • for every nonstatic data member that has class type or array of class type, that type * has trivial destructor.
  • *
- * Similar to std::tr1::has_trivial_destructor. + * Similar to {@code std::tr1::has_trivial_destructor}. * * @param classType the class to check - * @return true if the class has a trivial destructor + * @return {@code true} if the class has a trivial destructor */ public static boolean hasTrivialDestructor(ICPPClassType classType, IASTNode point) { for (ICPPMethod method : ClassTypeHelper.getDeclaredMethods(classType, point)) { @@ -280,11 +294,11 @@ } /** - * Returns true if and only if the given class declares or inherits a virtual - * function. Similar to std::tr1::is_polymorphic. + * Returns {@code true} if and only if the given class declares or inherits a virtual + * function. Similar to {@code std::tr1::is_polymorphic}. * * @param classType the class to check - * @return true if the class declares or inherits a virtual function. + * @return {@code true} if the class declares or inherits a virtual function. */ public static boolean isPolymorphic(ICPPClassType classType, IASTNode point) { if (hasDeclaredVirtualMethod(classType, point)) @@ -310,12 +324,12 @@ } /** - * Returns the compiler-generated copy constructor for the given class, or null + * Returns the compiler-generated copy constructor for the given class, or {@code null} * if the class doesn't have a compiler-generated copy constructor. * * @param classType the class to get the copy ctor for. - * @return the compiler-generated copy constructor, or null if the class doesn't - * have a compiler-generated copy constructor. + * @return the compiler-generated copy constructor, or {@code null} if the class doesn't + * have a compiler-generated copy constructor. */ private static ICPPConstructor getImplicitCopyCtor(ICPPClassType classType, IASTNode point) { for (ICPPConstructor ctor : ClassTypeHelper.getConstructors(classType, point)) { @@ -342,17 +356,11 @@ } else { ICPPEnumeration enumeration = (ICPPEnumeration) type; - // [dcl.enum] p5 - // "The underlying type can be explicitly specified using enum-base; - // if not explicitly specified, the underlying type of a scoped - // enumeration type is int." IType fixedType = enumeration.getFixedType(); if (fixedType != null) return fixedType; - if (enumeration.isScoped()) - return CPPVisitor.INT_TYPE; - // [dcl.enum] p6 + // [dcl.enum] 7.2-6: // "For an enumeration whose underlying type is not fixed, the // underlying type is an integral type that can represent all // the numerator values defined in the enumeration. ... It is @@ -363,30 +371,24 @@ // the underlying type is as if the enumeration had a single // enumerator with value 0." if (enumeration.getEnumerators().length == 0) - return CPPVisitor.INT_TYPE; - if (enumeration.getMinValue() < 0 || enumeration.getMaxValue() < 0) { - return smallestFittingType(enumeration, - CPPVisitor.INT_TYPE, - CPPVisitor.LONG_TYPE, - CPPVisitor.LONG_LONG_TYPE, - CPPVisitor.INT128_TYPE); + return CPPBasicType.INT; + long minValue = enumeration.getMinValue(); + long maxValue = enumeration.getMaxValue(); + if (minValue < 0 || maxValue < 0) { + return smallestFittingType(minValue, maxValue, SIGNED_UNDERLYING_ENUM_TYPES); } else { - return smallestFittingType(enumeration, - CPPVisitor.UNSIGNED_INT, - CPPVisitor.UNSIGNED_LONG, - CPPVisitor.UNSIGNED_LONG_LONG, - CPPVisitor.UNSIGNED_INT128); + return smallestFittingType(minValue, maxValue, UNSIGNED_UNDERLYING_ENUM_TYPES); } } } - - private static IBasicType smallestFittingType(ICPPEnumeration enumeration, ICPPBasicType... types) { - for (int i = 0; i < types.length - 1; ++i) { - if (ArithmeticConversion.fitsIntoType(types[i], enumeration.getMinValue()) - && ArithmeticConversion.fitsIntoType(types[i], enumeration.getMaxValue())) { - return types[i]; + + private static IBasicType smallestFittingType(long minValue, long maxValue, ICPPBasicType[] types) { + for (ICPPBasicType type : types) { + if (ArithmeticConversion.fitsIntoType(type, minValue) + && ArithmeticConversion.fitsIntoType(type, maxValue)) { + return type; } } - return types[types.length - 1]; // assume it fits into the largest type provided + return types[types.length - 1]; // Assume it fits into the largest type provided. } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java 2015-02-11 19:19:10.000000000 +0000 @@ -153,7 +153,6 @@ function("bool", "__atomic_compare_exchange", typePtr, typePtr, typePtr, "int", "int", "int"); function(type, "__atomic_add_fetch", typePtr, type, "int"); function(type, "__atomic_sub_fetch", typePtr, type, "int"); - function(type, "__atomic_add_fetch", typePtr, type, "int"); function(type, "__atomic_and_fetch", typePtr, type, "int"); function(type, "__atomic_xor_fetch", typePtr, type, "int"); function(type, "__atomic_or_fetch", typePtr, type, "int"); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2014 Wind River Systems, 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 @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -17,10 +18,20 @@ */ public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifier { /** - * Notifies that the value computation for the enumeration is started. Returns whether this is - * the first attempt to do so. + * Notifies that the value computation for the enumeration has started. + * Returns {@code true} if this is the first attempt to do so. */ boolean startValueComputation(); + + /** + * Notifies that the value computation for the enumeration has finished. + */ + void finishValueComputation(); + + /** + * Returns {@code true} if the value computation has started but hasn't finished yet. + */ + boolean isValueComputationInProgress(); /** * @since 5.1 diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IInternalVariable.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IInternalVariable.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IInternalVariable.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IInternalVariable.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, 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: - * Markus Schorn - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.parser; - -import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.IVariable; - -/** - * Internal interface for bindings in the ast that have values. - */ -public interface IInternalVariable extends IVariable { - /** - * Returns the value of the variable, or null. - * If the recursion depth is reached {@link Value#UNKNOWN} will be returned. - */ - IValue getInitialValue(int maxRecursionDepth); -} diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java 2015-02-11 19:19:10.000000000 +0000 @@ -39,6 +39,7 @@ final static byte DEFERRED_CLASS_INSTANCE = 0x0E; final static byte ALIAS_TEMPLATE = 0x0F; final static byte TYPE_TRANSFORMATION = 0x10; + final static byte UNKNOWN_MEMBER_TYPE = 0x11; // Can add more types up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE. final static byte diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java 2015-02-11 19:19:10.000000000 +0000 @@ -143,79 +143,51 @@ return msg; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() - */ @Override public String getName() { return node instanceof IASTName ? new String(((IASTName) node).getSimpleID()) : CPPSemantics.EMPTY_NAME; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray() - */ @Override public char[] getNameCharArray() { return node instanceof IASTName ? ((IASTName) node).getSimpleID() : CharArrayUtils.EMPTY; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() - */ @Override public IScope getScope() throws DOMException { throw new DOMException(this); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode() - */ @Override public IASTNode getPhysicalNode() { return getASTNode(); } - @Override public Object clone() { - // Don't clone problems + // Don't clone problems. return this; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getParent() - */ @Override public IScope getParent() throws DOMException { throw new DOMException(this); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) - */ @Override public IBinding[] find(String name) { return IBinding.EMPTY_BINDING_ARRAY; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName() - */ @Override public IName getScopeName() { return null; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName) - */ @Override public void addName(IASTName name) { } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) - */ @Override public IBinding getBinding(IASTName name, boolean resolve) { return null; @@ -226,37 +198,22 @@ return IBinding.EMPTY_BINDING_ARRAY; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) - */ @Override public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { return null; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) - */ - /** - * @deprecated Use {@link #getBindings(ScopeLookupData)} instead - */ @Deprecated @Override public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) { return getBindings(new ScopeLookupData(name, resolve, prefixLookup)); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) - */ @Override public IBinding[] getBindings(ScopeLookupData lookup) { return IBinding.EMPTY_BINDING_ARRAY; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) - */ @Override public boolean isSameType(IType type) { return type == this; @@ -320,76 +277,99 @@ public void removeNestedFromCache(IASTNode container) { } - // Dummy methods for derived classes + // Dummy methods for derived classes. public IType getType() { return new ProblemType(getID()); } + public boolean isStatic() { return false; } + public String[] getQualifiedName() throws DOMException { throw new DOMException(this); } + public char[][] getQualifiedNameCharArray() throws DOMException { throw new DOMException(this); } + public boolean isGloballyQualified() throws DOMException { throw new DOMException(this); } + public boolean isMutable() { return false; } + public boolean isExtern() { return false; } + public boolean isExternC() { return false; } + public boolean isAuto() { return false; } + public boolean isRegister() { return false; } - public IValue getInitialValue() { + + public IValue getInitialValue() { return null; } - public boolean isAnonymous() { + + public boolean isAnonymous() { return false; } - public boolean isDeleted() { + + public boolean isDeleted() { return false; } + public boolean isInline() { return false; } + public boolean takesVarArgs() { return false; } - public IType[] getExceptionSpecification() { + + public IType[] getExceptionSpecification() { return null; } + public boolean hasParameterPack() { return false; } + public boolean isVirtual() { return false; } + public boolean isPureVirtual() { return false; } + public boolean isImplicit() { return false; } - public boolean isExplicit() { + + public boolean isExplicit() { return false; } + public boolean hasDefaultValue() { return false; } + public IValue getDefaultValue() { return null; } + public boolean isParameterPack() { return false; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2010, 2014 Wind River Systems, 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 @@ -56,6 +56,16 @@ return false; } + @Override + public boolean hasRefQualifier() { + return false; + } + + @Override + public boolean isRValueReference() { + return false; + } + @Override public boolean takesVarArgs() { return false; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2013 Google, Inc and others. + * Copyright (c) 2011, 2014 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 @@ -30,12 +30,12 @@ import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits; /** * Calculator of in-memory size and alignment of types. @@ -85,7 +85,7 @@ * @param type the type to get size and alignment for. * @param point a node belonging to the AST of the translation unit defining context for * the size calculation. - * @return size and alignment, or null if could not be calculated. + * @return size and alignment, or {@code null} if could not be calculated. */ public static SizeAndAlignment getSizeAndAlignment(IType type, IASTNode point) { SizeofCalculator calc = point == null ? @@ -173,7 +173,7 @@ /** * Calculates size and alignment for the given type. * @param type the type to get size and alignment for. - * @return size and alignment, or null if could not be calculated. + * @return size and alignment, or {@code null} if could not be calculated. */ public SizeAndAlignment sizeAndAlignment(IType type) { type = SemanticUtil.getNestedType(type, SemanticUtil.CVTYPE | SemanticUtil.TDEF); @@ -183,8 +183,8 @@ if (type instanceof IBasicType) { return sizeAndAlignment((IBasicType) type); } - // [expr.sizeof]/2: "When applied to a reference or a reference type, the - // result is the size of the referenced type." + // [expr.sizeof]/2: "When applied to a reference or a reference type, + // the result is the size of the referenced type." if (type instanceof ICPPReferenceType) { return sizeAndAlignment(((ICPPReferenceType) type).getType()); } @@ -207,7 +207,7 @@ /** * Returns size and alignment of pointer types. - * @return size and alignment of pointer types, or null if unknown. + * @return size and alignment of pointer types, or {@code null} if unknown. */ public SizeAndAlignment sizeAndAlignmentOfPointer() { return sizeof_pointer; @@ -247,24 +247,11 @@ } private SizeAndAlignment sizeAndAlignment(IEnumeration type) { - if (type instanceof ICPPEnumeration) { - IType fixedType = ((ICPPEnumeration) type).getFixedType(); - if (fixedType != null) { - return sizeAndAlignment(fixedType); - } + IType underlyingType = TypeTraits.underlyingType(type); + if (underlyingType instanceof IBasicType) { + return sizeAndAlignment((IBasicType) underlyingType); } - long range = Math.max(Math.abs(type.getMinValue()) - 1, Math.abs(type.getMaxValue())); - if (range >= (2 << 32)) - return size_8; - if (type.getMinValue() < 0) - range *= 2; - if (range >= (2 << 32)) - return size_8; - if (range >= (2 << 16)) - return size_4; - if (range >= (2 << 8)) - return size_2; - return SIZE_1; + return null; } private SizeAndAlignment sizeAndAlignment(IArrayType type) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2014 Wind River Systems, 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 @@ -56,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; @@ -216,6 +217,9 @@ return CharArrayUtils.equals(getSignature(), rhs.getSignature()); } + /** + * For debugging only. + */ @Override public String toString() { return new String(getSignature()); @@ -356,11 +360,12 @@ case __is_base_of: type1 = SemanticUtil.getNestedType(type1, TDEF); type2 = SemanticUtil.getNestedType(type2, TDEF); - if (type1 instanceof ICPPClassType && type2 instanceof ICPPClassType) { - return ClassTypeHelper.isSubclass((ICPPClassType) type2, (ICPPClassType) type1, point) ? 1 : 0; - } else { - return 0; + if (type1 instanceof ICPPClassType && type2 instanceof ICPPClassType && + (type1.isSameType(type2) || + ClassTypeHelper.isSubclass((ICPPClassType) type2, (ICPPClassType) type1, point))) { + return 1; } + return 0; } return VALUE_CANNOT_BE_DETERMINED; } @@ -416,8 +421,8 @@ /** * Creates the value for an expression. */ - public static IValue create(IASTExpression expr, int maxRecursionDepth) { - Number val= evaluate(expr, maxRecursionDepth); + public static IValue create(IASTExpression expr) { + Number val= evaluate(expr); if (val == VALUE_CANNOT_BE_DETERMINED) return UNKNOWN; if (val != null) @@ -452,38 +457,38 @@ * Returns a {@code Number} for numerical values or {@code null}, otherwise. * @throws UnknownValueException */ - private static Number evaluate(IASTExpression exp, int maxdepth) { - if (maxdepth < 0 || exp == null) + private static Number evaluate(IASTExpression exp) { + if (exp == null) return VALUE_CANNOT_BE_DETERMINED; if (exp instanceof IASTArraySubscriptExpression) { return VALUE_CANNOT_BE_DETERMINED; } if (exp instanceof IASTBinaryExpression) { - return evaluateBinaryExpression((IASTBinaryExpression) exp, maxdepth); + return evaluateBinaryExpression((IASTBinaryExpression) exp); } if (exp instanceof IASTCastExpression) { // must be ahead of unary - return evaluate(((IASTCastExpression) exp).getOperand(), maxdepth); + return evaluate(((IASTCastExpression) exp).getOperand()); } if (exp instanceof IASTUnaryExpression) { - return evaluateUnaryExpression((IASTUnaryExpression) exp, maxdepth); + return evaluateUnaryExpression((IASTUnaryExpression) exp); } if (exp instanceof IASTConditionalExpression) { IASTConditionalExpression cexpr= (IASTConditionalExpression) exp; - Number v= evaluate(cexpr.getLogicalConditionExpression(), maxdepth); + Number v= evaluate(cexpr.getLogicalConditionExpression()); if (v == null || v == VALUE_CANNOT_BE_DETERMINED) return v; if (v.longValue() == 0) { - return evaluate(cexpr.getNegativeResultExpression(), maxdepth); + return evaluate(cexpr.getNegativeResultExpression()); } final IASTExpression pe = cexpr.getPositiveResultExpression(); if (pe == null) // gnu-extension allows to omit the positive expression. return v; - return evaluate(pe, maxdepth); + return evaluate(pe); } if (exp instanceof IASTIdExpression) { IBinding b= ((IASTIdExpression) exp).getName().resolvePreBinding(); - return evaluateBinding(b, maxdepth); + return evaluateBinding(b); } if (exp instanceof IASTLiteralExpression) { IASTLiteralExpression litEx= (IASTLiteralExpression) exp; @@ -527,7 +532,7 @@ return null; return applyBinaryTypeIdOperator(typeIdExp.getOperator(), t1, t2, exp); } - if (exp instanceof IASTFunctionCallExpression) { + if (exp instanceof IASTFunctionCallExpression || exp instanceof ICPPASTSimpleTypeConstructorExpression) { return null; // The value will be obtained from the evaluation. } return VALUE_CANNOT_BE_DETERMINED; @@ -536,7 +541,7 @@ /** * Extract a value off a binding. */ - private static Number evaluateBinding(IBinding b, int maxdepth) { + private static Number evaluateBinding(IBinding b) { if (b instanceof IType) { return VALUE_CANNOT_BE_DETERMINED; } @@ -549,9 +554,7 @@ } IValue value= null; - if (b instanceof IInternalVariable) { - value= ((IInternalVariable) b).getInitialValue(maxdepth - 1); - } else if (b instanceof IVariable) { + if (b instanceof IVariable) { value= ((IVariable) b).getInitialValue(); } else if (b instanceof IEnumerator) { value= ((IEnumerator) b).getValue(); @@ -563,7 +566,7 @@ return VALUE_CANNOT_BE_DETERMINED; } - private static Number evaluateUnaryExpression(IASTUnaryExpression exp, int maxdepth) { + private static Number evaluateUnaryExpression(IASTUnaryExpression exp) { final int unaryOp= exp.getOperator(); if (unaryOp == IASTUnaryExpression.op_sizeof) { @@ -586,7 +589,7 @@ return VALUE_CANNOT_BE_DETERMINED; } - final Number value= evaluate(exp.getOperand(), maxdepth); + final Number value= evaluate(exp.getOperand()); if (value == null || value == VALUE_CANNOT_BE_DETERMINED) return value; return applyUnaryOperator(unaryOp, value.longValue()); @@ -616,7 +619,7 @@ return VALUE_CANNOT_BE_DETERMINED; } - private static Number evaluateBinaryExpression(IASTBinaryExpression exp, int maxdepth) { + private static Number evaluateBinaryExpression(IASTBinaryExpression exp) { final int op= exp.getOperator(); switch (op) { case IASTBinaryExpression.op_equals: @@ -629,10 +632,10 @@ break; } - final Number o1= evaluate(exp.getOperand1(), maxdepth); + final Number o1= evaluate(exp.getOperand1()); if (o1 == null || o1 == VALUE_CANNOT_BE_DETERMINED) return o1; - final Number o2= evaluate(exp.getOperand2(), maxdepth); + final Number o2= evaluate(exp.getOperand2()); if (o2 == null || o2 == VALUE_CANNOT_BE_DETERMINED) return o2; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java 2015-02-11 19:19:10.000000000 +0000 @@ -75,7 +75,7 @@ } @Override - public ASTNodeProperty getPropertyInParent() { + public final ASTNodeProperty getPropertyInParent() { return null; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java 2015-02-11 19:19:10.000000000 +0000 @@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; @@ -142,6 +143,17 @@ scribe.printSpace(); scribe.print(Keywords.VOLATILE); } + RefQualifier refQualifier = funcDec.getRefQualifier(); + if (refQualifier != null) { + switch (refQualifier) { + case LVALUE: + scribe.print(Keywords.cpAMPER); + break; + case RVALUE: + scribe.print(Keywords.cpAND); + break; + } + } if (funcDec.isMutable()) { scribe.printSpace(); scribe.print(Keywords.MUTABLE); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Tomasz Wesolowski + * Copyright (c) 2010, 2014 Tomasz Wesolowski * 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 @@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; @@ -128,18 +129,19 @@ IASTDeclarator returnedDeclarator = null; try { - // Addition of pointer operators has to be in reverse order, so it's deferred until the end + // Addition of pointer operators has to be in reverse order, so it's deferred until + // the end. Map> pointerOperatorMap = new HashMap>(); IASTName newName = name != null ? factory.newName(name) : factory.newName(); - // If the type is an array of something, create a declaration of a pointer to something instead - // (to allow assignment, etc) + // If the type is an array of something, create a declaration of a pointer to something + // instead (to allow assignment, etc). boolean replaceInitialArrayWithPointer = true; // If the type is a function, create a declaration of a pointer to this function - // (shorthand notation for function address) + // (shorthand notation for function address). boolean changeInitialFunctionToFuncPtr = true; @@ -151,7 +153,7 @@ } else if (changeInitialFunctionToFuncPtr && type instanceof IFunctionType) { returnedDeclarator = factory.newDeclarator(newName); returnedDeclarator.addPointerOperator(factory.newPointer()); - // leave type as it is, next iteration will handle the function + // Leave type as it is, next iteration will handle the function. } else if (type instanceof IArrayType) { IArrayType arrayType = (IArrayType) type; IASTArrayDeclarator arrayDeclarator = factory.newArrayDeclarator(null); @@ -161,7 +163,7 @@ arrayDeclarator.setNestedDeclarator(returnedDeclarator); arrayDeclarator.setName(factory.newName()); } - // consume all immediately following array expressions + // Consume all immediately following array expressions. while (type instanceof IArrayType) { arrayType = (IArrayType) type; IASTExpression arraySizeExpression = arrayType.getArraySizeExpression(); @@ -233,7 +235,7 @@ IASTDeclarator returnedDeclarator, IASTPointerOperator ptrOp) { LinkedList list; if (!pointerOperatorMap.containsKey(returnedDeclarator)) { - list = new LinkedList(); + list = new LinkedList<>(); pointerOperatorMap.put(returnedDeclarator, list); } else { list = pointerOperatorMap.get(returnedDeclarator); @@ -289,13 +291,12 @@ ICPPASTTemplateId tempId = getTemplateId(type, templateName); ICPPASTQualifiedName newQualifiedName = - ((ICPPNodeFactory) factory).newQualifiedName(); + ((ICPPNodeFactory) factory).newQualifiedName(tempId); ICPPASTNameSpecifier[] qualifier = fullQualifiedName.getQualifier(); int nbQualifiedNames = qualifier.length; for (int i = 0; i < nbQualifiedNames; i++) { newQualifiedName.addNameSpecifier(qualifier[i].copy(CopyStyle.withLocations)); } - newQualifiedName.setLastName(tempId); return factory.newTypedefNameSpecifier(newQualifiedName); } else { @@ -329,9 +330,13 @@ char[][] qualifiedNameCharArray = CPPVisitor.getQualifiedNameCharArray(binding); IASTName name; if (qualifiedNameCharArray.length > 1) { - name = ((ICPPNodeFactory) factory).newQualifiedName(); - for (char[] cs : qualifiedNameCharArray) { - ((ICPPASTQualifiedName) name).addName(factory.newName(cs)); + char[] cs = qualifiedNameCharArray[qualifiedNameCharArray.length - 1]; + ICPPNodeFactory cppFactory = (ICPPNodeFactory) factory; + ICPPASTName segment = cppFactory.newName(cs); + name = cppFactory.newQualifiedName(segment); + for (int i = 0; i < qualifiedNameCharArray.length - 1; i++) { + segment = cppFactory.newName(cs); + ((ICPPASTQualifiedName) name).addNameSpecifier(cppFactory.newName(qualifiedNameCharArray[i])); } } else if (qualifiedNameCharArray.length == 1) { name = factory.newName(qualifiedNameCharArray[0]); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,15 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Symbian Software Systems and others. + * Copyright (c) 2007, 2015 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.c; +import org.eclipse.cdt.core.dom.ast.EScopeKind; import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; @@ -46,27 +48,23 @@ super(index); } - /* - * @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeScope(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IScope) - */ @Override public IIndexScope getCompositeScope(IIndexScope rscope) { - if(rscope==null) + if (rscope == null) return null; - if(rscope instanceof ICCompositeTypeScope) { + if (rscope.getKind() == EScopeKind.eGlobal) + return rscope; + + if (rscope instanceof ICCompositeTypeScope) { ICCompositeTypeScope cscope = (ICCompositeTypeScope) rscope; IIndexFragmentBinding rbinding = (IIndexFragmentBinding) cscope.getCompositeType(); - return (IIndexScope) ((ICompositeType)getCompositeBinding(rbinding)).getCompositeScope(); + return (IIndexScope) ((ICompositeType) getCompositeBinding(rbinding)).getCompositeScope(); } throw new CompositingNotImplementedError(); } - /* - * @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType) - */ @Override public IType getCompositeType(IType rtype) { - if (rtype instanceof IIndexFragmentBinding) { return (IType) getCompositeBinding((IIndexFragmentBinding) rtype); } @@ -138,28 +136,28 @@ public IIndexBinding getCompositeBinding(IIndexFragmentBinding rbinding) { IIndexBinding result; - if(rbinding==null) { + if (rbinding == null) { result = null; - } else if(rbinding instanceof IParameter) { + } else if (rbinding instanceof IParameter) { result = new CompositeCParameter(this, rbinding); - } else if(rbinding instanceof IField) { + } else if (rbinding instanceof IField) { result = new CompositeCField(this, rbinding); - } else if(rbinding instanceof IVariable) { + } else if (rbinding instanceof IVariable) { result = new CompositeCVariable(this, rbinding); - } else if(rbinding instanceof ICompositeType) { + } else if (rbinding instanceof ICompositeType) { result = new CompositeCStructure(this, findOneBinding(rbinding, false)); - } else if(rbinding instanceof IEnumeration) { + } else if (rbinding instanceof IEnumeration) { result = new CompositeCEnumeration(this, findOneBinding(rbinding, false)); - } else if(rbinding instanceof IFunction) { + } else if (rbinding instanceof IFunction) { result = new CompositeCFunction(this, rbinding); - } else if(rbinding instanceof IEnumerator) { + } else if (rbinding instanceof IEnumerator) { result = new CompositeCEnumerator(this, rbinding); - } else if(rbinding instanceof ITypedef) { + } else if (rbinding instanceof ITypedef) { result = new CompositeCTypedef(this, rbinding); - } else if(rbinding instanceof IIndexMacroContainer) { + } else if (rbinding instanceof IIndexMacroContainer) { result= new CompositeMacroContainer(this, rbinding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for "+rbinding+" "+rbinding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + rbinding + " " + rbinding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } return result; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCCompositeScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCCompositeScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCCompositeScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCCompositeScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.c; @@ -39,7 +39,7 @@ @Override public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { - IBinding binding = ((ICompositeType)rbinding).getCompositeScope().getBinding(name, resolve, fileSet); + IBinding binding = ((ICompositeType) rbinding).getCompositeScope().getBinding(name, resolve, fileSet); return processUncertainBinding(binding); } @@ -50,13 +50,13 @@ @Override public IBinding[] getBindings(ScopeLookupData lookup) { - IBinding[] bindings = ((ICompositeType)rbinding).getCompositeScope().getBindings(lookup); + IBinding[] bindings = ((ICompositeType) rbinding).getCompositeScope().getBindings(lookup); return processUncertainBindings(bindings); } @Override public IBinding[] find(String name) { - IBinding[] preresult = ((ICompositeType)rbinding).getCompositeScope().find(name); + IBinding[] preresult = ((ICompositeType) rbinding).getCompositeScope().find(name); return processUncertainBindings(preresult); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -38,7 +38,9 @@ protected final IIndexFragmentBinding rbinding; public CompositeScope(ICompositesFactory cf, IIndexFragmentBinding rbinding) { - if (cf == null || rbinding == null) + if (cf == null) + throw new NullPointerException(); + if (rbinding == null) throw new NullPointerException(); this.cf = cf; this.rbinding = rbinding; @@ -66,7 +68,6 @@ throw new CompositingNotImplementedError(); } - public IBinding getRawScopeBinding() { return rbinding; } @@ -84,8 +85,7 @@ return binding; } else if (binding instanceof CPPCompositeBinding /* AST composite */) { return new CPPCompositeBinding( - processUncertainBindings(((CPPCompositeBinding) binding).getBindings()) - ); + processUncertainBindings(((CPPCompositeBinding) binding).getBindings())); } else if (binding instanceof CPPUsingDeclaration) { return binding; } else if (binding == null) { @@ -98,8 +98,10 @@ } /** - * A convenience method for processing an array of bindings with {@link CompositeScope#processUncertainBinding(IBinding)} - * Returns an empty array if the input parameter is null + * A convenience method for processing an array of bindings with + * {@link CompositeScope#processUncertainBinding(IBinding)}. + * Returns an empty array if the input parameter is null. + * * @param frgBindings * @return a non-null IBinding[] */ @@ -125,19 +127,19 @@ } /** - * The c++-name resolution stores scopes in hash-maps, we need to make sure equality is detected + * The c++ name resolution stores scopes in hash-maps, we need to make sure equality is detected * in order to prevent infinite loops. */ @Override public final boolean equals(Object other) { if (other instanceof CompositeScope) { - return rbinding.equals(((CompositeScope)other).rbinding); + return rbinding.equals(((CompositeScope) other).rbinding); } return false; } /** - * The c++-name resolution stores scopes in hash-maps, we need to make sure equality is detected + * The c++ name resolution stores scopes in hash-maps, we need to make sure equality is detected * in order to prevent infinite loops. */ @Override diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumerator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumerator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumerator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumerator.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2014 Symbian Software Systems 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 @@ -7,32 +7,38 @@ * * Contributors: * Andrew Ferguson (Symbian) - Initial implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; -import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalEnumerator; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; -class CompositeCPPEnumerator extends CompositeCPPBinding implements IEnumerator { - public CompositeCPPEnumerator(ICompositesFactory cf, IEnumerator rbinding) { +class CompositeCPPEnumerator extends CompositeCPPBinding implements ICPPInternalEnumerator { + public CompositeCPPEnumerator(ICompositesFactory cf, ICPPInternalEnumerator rbinding) { super(cf, rbinding); } @Override public IType getType() { - IType type = ((IEnumerator) rbinding).getType(); + IType type = ((ICPPInternalEnumerator) rbinding).getType(); return cf.getCompositeType(type); } @Override public IValue getValue() { - return ((IEnumerator) rbinding).getValue(); + return ((ICPPInternalEnumerator) rbinding).getValue(); } @Override public String toString() { return getName(); } + + @Override + public IType getInternalType() { + return ((ICPPInternalEnumerator) rbinding).getInternalType(); + } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeratorSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeratorSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeratorSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeratorSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Google, Inc and others. + * Copyright (c) 2013, 2014 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 @@ -11,15 +11,15 @@ package org.eclipse.cdt.internal.core.index.composite.cpp; import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalEnumerator; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; class CompositeCPPEnumeratorSpecialization extends CompositeCPPEnumerator implements ICPPSpecialization { - public CompositeCPPEnumeratorSpecialization(ICompositesFactory cf, IEnumerator delegate) { + public CompositeCPPEnumeratorSpecialization(ICompositesFactory cf, ICPPInternalEnumerator delegate) { super(cf, delegate); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPNamespaceScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -51,7 +51,7 @@ @Override public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) { IBinding preresult = null; - for(int i=0; preresult==null && inull if the scope is nested in the global scope. + * Returns the parent scope or {@code null} if the scope is nested in the global scope. */ @Override IIndexScope getParent(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java 2015-02-11 19:19:10.000000000 +0000 @@ -1165,12 +1165,12 @@ } public static String getAbsoluteInclusionPath(String includeDirective, String currentFile) { - // Filename is an absolute path + // Filename is an absolute path. if (new File(includeDirective).isAbsolute()) { return includeDirective; } - // Filename is a Linux absolute path on a Windows machine - if (File.separatorChar == '\\' && includeDirective.length() > 0) { + // Filename is a Linux absolute path on a Windows machine. + if (File.separatorChar == '\\' && !includeDirective.isEmpty()) { final char firstChar = includeDirective.charAt(0); if (firstChar == '\\' || firstChar == '/') { if (currentFile != null && currentFile.length() > 1 && currentFile.charAt(1) == ':') { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroDefinitionParser.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroDefinitionParser.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroDefinitionParser.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroDefinitionParser.java 2015-02-11 19:19:10.000000000 +0000 @@ -234,12 +234,12 @@ default: throw new InvalidMacroDefinitionException(name.getCharImage(), name.getOffset(), param.getEndOffset()); } - } - while (fHasVarArgs==0 && next.getType() == IToken.tCOMMA); + } while (fHasVarArgs == 0 && next.getType() == IToken.tCOMMA); + if (next.getType() != IToken.tRPAREN) { throw new InvalidMacroDefinitionException(name.getCharImage(), name.getOffset(), next.getEndOffset()); } - next= lex.nextToken(); // consume the closing parenthesis + next= lex.nextToken(); // Consume the closing parenthesis. return paramList.toArray(new char[paramList.size()][]); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java 2015-02-11 19:19:10.000000000 +0000 @@ -1248,7 +1248,9 @@ ArrayList orderedFileKeys= new ArrayList<>(); final IIndexFileLocation topIfl = fResolver.resolveASTPath(ast.getFilePath()); - FileContentKey topKey = new FileContentKey(linkageID, topIfl, ast.getSignificantMacros()); + ISignificantMacros significantMacros = ast.isHeaderUnit() ? + ast.getSignificantMacros() : ISignificantMacros.NONE; + FileContentKey topKey = new FileContentKey(linkageID, topIfl, significantMacros); enteredFiles.add(topKey); IDependencyTree tree= ast.getDependencyTree(); IASTInclusionNode[] inclusions= tree.getInclusions(); @@ -1256,7 +1258,7 @@ collectOrderedFileKeys(linkageID, inclusion, enteredFiles, orderedFileKeys); } - IIndexFragmentFile newFile= selectIndexFile(linkageID, topIfl, ast.getSignificantMacros()); + IIndexFragmentFile newFile= selectIndexFile(linkageID, topIfl, significantMacros); if (ctx != null) { orderedFileKeys.add(new FileInAST(topKey, codeReader)); // File can be reused diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCGlobalScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCGlobalScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCGlobalScope.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCGlobalScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2015 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.pdom.dom.c; + +import org.eclipse.cdt.core.dom.ast.c.ICScope; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMGlobalScope; + +/** + * Represents the global C index scope. + */ +public class PDOMCGlobalScope extends PDOMGlobalScope implements ICScope { + public static final PDOMCGlobalScope INSTANCE = new PDOMCGlobalScope(); + + private PDOMCGlobalScope() {} +} diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java 2015-02-11 19:19:10.000000000 +0000 @@ -43,6 +43,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner; import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMGlobalScope; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.core.runtime.CoreException; @@ -128,8 +129,16 @@ PDOMNode insertIntoIndex= null; if (binding instanceof IField) { // must be before IVariable - if (parent instanceof IPDOMMemberOwner) + if (parent instanceof IPDOMMemberOwner) { pdomBinding = new PDOMCField(this, (IPDOMMemberOwner)parent, (IField) binding); + // If the field is inside an anonymous struct or union, add it to the parent node as well. + if (parent instanceof ICompositeType && ((ICompositeType) parent).isAnonymous()) { + insertIntoIndex = parent.getParentNode(); + if (insertIntoIndex == null) { + insertIntoIndex = this; + } + } + } } else if (binding instanceof IVariable) { IVariable var= (IVariable) binding; pdomBinding = new PDOMCVariable(this, parent, var); @@ -334,6 +343,11 @@ return new FindBinding.DefaultBindingBTreeComparator(this); } + @Override + public PDOMGlobalScope getGlobalScope() { + return PDOMCGlobalScope.INSTANCE; + } + @Override public PDOMBinding addTypeBinding(IBinding type) throws CoreException { return addBinding(type, null); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java 2015-02-11 19:19:10.000000000 +0000 @@ -45,7 +45,6 @@ /** * @author Doug Schaefer - * */ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCompositeTypeScope, IPDOMMemberOwner, IIndexType, IIndexScope { private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE; @@ -58,7 +57,7 @@ super(linkage, parent, compType.getNameCharArray()); setKind(compType); setAnonymous(compType); - // linked list is initialized by malloc zeroing allocated storage + // Linked list is initialized by malloc zeroing allocated storage. } public PDOMCStructure(PDOMLinkage linkage, long record) { @@ -88,7 +87,6 @@ getDB().putByte(record + ANONYMOUS, (byte) (ct.isAnonymous() ? 1 : 0)); } - @Override public void accept(IPDOMVisitor visitor) throws CoreException { super.accept(visitor); @@ -126,7 +124,7 @@ } private static class GetFields implements IPDOMVisitor { - private final List fields = new ArrayList(); + private final List fields = new ArrayList<>(); @Override public boolean visit(IPDOMNode node) throws CoreException { if (node instanceof IField) { @@ -156,20 +154,22 @@ return fields.getFields(); } catch (CoreException e) { CCorePlugin.log(e); - return new IField[0]; + return IField.EMPTY_FIELD_ARRAY; } } public static class FindField implements IPDOMVisitor { private IField field; private final String name; + public FindField(String name) { this.name = name; } + @Override public boolean visit(IPDOMNode node) throws CoreException { if (node instanceof IField) { - IField tField = (IField)node; + IField tField = (IField) node; if (IndexFilter.ALL_DECLARED_OR_IMPLICIT.acceptBinding(tField)) { if (name.equals(tField.getName())) { field = tField; @@ -183,10 +183,14 @@ } return false; } + @Override public void leave(IPDOMNode node) throws CoreException { } - public IField getField() { return field; } + + public IField getField() { + return field; + } } @Override @@ -254,7 +258,7 @@ @Override public void addChild(PDOMNode member) throws CoreException { - new PDOMNodeLinkedList(getLinkage(), record+MEMBERLIST).addMember(member); + new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST).addMember(member); } @Override @@ -296,9 +300,9 @@ IBinding b= getBinding(name); if (b == null) return IBinding.EMPTY_BINDING_ARRAY; - return new IBinding[]{b}; + return new IBinding[] { b }; } - + @Override public IIndexBinding getScopeBinding() { return this; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumerator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumerator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumerator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/IPDOMCPPEnumerator.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Google, Inc and others. + * Copyright (c) 2013, 2014 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 @@ -10,11 +10,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; -import org.eclipse.cdt.core.dom.ast.IEnumerator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalEnumerator; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding; /** * Interface for a c++ enumerator stored in the index. */ -public interface IPDOMCPPEnumerator extends IEnumerator, IPDOMBinding { +public interface IPDOMCPPEnumerator extends ICPPInternalEnumerator, IPDOMBinding { } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Symbian Corporation and others. + * Copyright (c) 2006, 2015 Symbian 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 @@ -8,14 +8,22 @@ * Contributors: * Symbian - Initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ 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.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; +import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.core.runtime.CoreException; @@ -49,4 +57,33 @@ // Local stuff is not stored in the index. return true; } + + @Override + public final IIndexScope getScope() { + // The parent node in the binding hierarchy is the scope. + try { + IBinding parent= getParentBinding(); + while (parent != null) { + if (parent instanceof ICPPClassType) { + return (IIndexScope) ((ICPPClassType) parent).getCompositeScope(); + } else if (parent instanceof ICPPUnknownBinding) { + return (IIndexScope) ((ICPPUnknownBinding) parent).asScope(); + } else if (parent instanceof ICPPEnumeration) { + final ICPPEnumeration enumeration = (ICPPEnumeration) parent; + if (enumeration.isScoped()) { + return (IIndexScope) enumeration.asScope(); + } + parent= ((PDOMNamedNode) parent).getParentBinding(); + } else if (parent instanceof IIndexScope) { + return (IIndexScope) parent; + } else { + break; + } + } + } catch (DOMException e) { + } catch (CoreException e) { + CCorePlugin.log(e); + } + return getLinkage().getGlobalScope(); + } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java 2015-02-11 19:19:10.000000000 +0000 @@ -40,12 +40,19 @@ @SuppressWarnings("hiding") protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE + 4; - public PDOMCPPClassInstance(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding orig) + private volatile ICPPTemplateArgument[] fTemplateArguments; + + public PDOMCPPClassInstance(PDOMCPPLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding orig) throws CoreException { super(linkage, parent, classType, orig); final ICPPTemplateInstance asInstance= (ICPPTemplateInstance) classType; - final long argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments()); - getDB().putRecPtr(record + ARGUMENTS, argListRec); + // Defer storing of template arguments to the post-process + // to avoid infinite recursion when the evaluation of a non-type + // template argument tries to store its template definition. + // Until the post-process runs, temporarily store the input (possibly + // non-PDOM) arguments. + fTemplateArguments = asInstance.getTemplateArguments(); + linkage.new ConfigureClassInstance(this); } public PDOMCPPClassInstance(PDOMLinkage linkage, long bindingRecord) { @@ -69,12 +76,29 @@ @Override public ICPPTemplateArgument[] getTemplateArguments() { + if (fTemplateArguments == null) { + try { + final long rec= getPDOM().getDB().getRecPtr(record + ARGUMENTS); + fTemplateArguments = PDOMCPPArgumentList.getArguments(this, rec); + } catch (CoreException e) { + CCorePlugin.log(e); + } + } + return fTemplateArguments; + } + + public void storeTemplateArguments() { try { - final long rec= getPDOM().getDB().getRecPtr(record + ARGUMENTS); - return PDOMCPPArgumentList.getArguments(this, rec); + // fTemplateArguments here are the temporarily stored, possibly non-PDOM + // arguments stored by the constructor. Construct the PDOM arguments and + // store them. + final long argListRec= PDOMCPPArgumentList.putArguments(this, fTemplateArguments); + getDB().putRecPtr(record + ARGUMENTS, argListRec); + + // Read the stored arguments next time getTemplateArguments() is called. + fTemplateArguments = null; } catch (CoreException e) { CCorePlugin.log(e); - return ICPPTemplateArgument.EMPTY_ARGUMENTS; } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -152,7 +152,8 @@ public IBinding[] getBindings(ScopeLookupData lookup) { try { if (lookup.getLookupName() instanceof ICPPASTConversionName) { - BindingCollector visitor = new BindingCollector(fBinding.getLinkage(), Keywords.cOPERATOR, CONVERSION_FILTER, true, false, true); + BindingCollector visitor = new BindingCollector(fBinding.getLinkage(), + Keywords.cOPERATOR, CONVERSION_FILTER, true, false, true); acceptViaCache(fBinding, visitor, true); return visitor.getBindings(); } @@ -171,10 +172,11 @@ return getBindingsViaCache(fBinding, nameChars, IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE); } - // prefix lookup - BindingCollector visitor = new BindingCollector(fBinding.getLinkage(), nameChars, IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, true, true, !true); + // Prefix lookup. + BindingCollector visitor = new BindingCollector(fBinding.getLinkage(), nameChars, + IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, true, true, false); if (ContentAssistMatcherFactory.getInstance().match(nameChars, fBinding.getNameCharArray())) { - // add the class itself, constructors will be found during the visit + // Add the class itself, constructors will be found during the visit. visitor.visit((IPDOMNode) getClassNameBinding()); } acceptViaCache(fBinding, visitor, true); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -53,8 +53,8 @@ /** * @author Bryan Wilkinson */ -class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements - ICPPClassSpecialization, IPDOMMemberOwner, IPDOMCPPClassType { +class PDOMCPPClassSpecialization extends PDOMCPPSpecialization + implements ICPPClassSpecialization, IPDOMMemberOwner, IPDOMCPPClassType { private static final int FIRST_BASE = PDOMCPPSpecialization.RECORD_SIZE + 0; private static final int MEMBERLIST = FIRST_BASE + 4; private static final int FINAL = MEMBERLIST + PDOMCPPMemberBlock.RECORD_SIZE; // byte @@ -66,15 +66,15 @@ protected static final int RECORD_SIZE = FINAL + 1; private volatile ICPPClassScope fScope; - private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache + private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache. private final ThreadLocal> fInProgress= new ThreadLocal>() { @Override protected Set initialValue() { - return new HashSet(); + return new HashSet<>(); } }; - public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType, + public PDOMCPPClassSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized) throws CoreException { super(linkage, parent, (ICPPSpecialization) classType, specialized); setFinal(classType); @@ -257,7 +257,7 @@ return bases; try { - List list = new ArrayList(); + List list = new ArrayList<>(); for (PDOMCPPBase base = getFirstBase(); base != null; base = base.getNextBase()) { list.add(base); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java 2015-02-11 19:19:10.000000000 +0000 @@ -244,7 +244,7 @@ } // Need a class template. - if (type instanceof ICPPClassTemplate == false || type instanceof ProblemBinding) + if (!(type instanceof ICPPClassTemplate) || type instanceof ProblemBinding) return false; // Exclude other kinds of class templates. diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java 2015-02-11 19:19:10.000000000 +0000 @@ -66,7 +66,7 @@ setKind(classType); setAnonymous(classType); setFinal(classType); - // Linked list is initialized by storage being zero'd by malloc + // Linked list is initialized by storage being zero'd by malloc. } public PDOMCPPClassType(PDOMLinkage linkage, long bindingRecord) { @@ -304,7 +304,7 @@ public ICPPBase[] getBases() { Long key= record + PDOMCPPLinkage.CACHE_BASES; ICPPBase[] bases= (ICPPBase[]) getPDOM().getCachedResult(key); - if (bases != null) + if (bases != null) return bases; try { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerationSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerationSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerationSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerationSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -57,7 +57,7 @@ private volatile IType fFixedType= ProblemBinding.NOT_INITIALIZED; private PDOMCPPEnumScope fScope; // No need for volatile, all fields of PDOMCPPEnumScope are final. - public PDOMCPPEnumerationSpecialization(PDOMLinkage linkage, PDOMNode parent, + public PDOMCPPEnumerationSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPEnumeration enumeration, PDOMBinding specialized) throws CoreException { super(linkage, parent, (ICPPSpecialization) enumeration, specialized); storeProperties(enumeration); @@ -258,6 +258,6 @@ return i < enumerators.length ? enumerators[i] : enumerator; } } - return null; + return enumerator; } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerator.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerator.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerator.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerator.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 QNX Software Systems and others. + * Copyright (c) 2006, 2014 QNX Software Systems 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 @@ -17,7 +17,9 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; +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.ICPPInternalEnumerator; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.pdom.db.Database; @@ -30,14 +32,22 @@ */ class PDOMCPPEnumerator extends PDOMCPPBinding implements IPDOMCPPEnumerator { private static final int VALUE= PDOMCPPBinding.RECORD_SIZE; + private static final int INTERNAL_TYPE= VALUE + Database.VALUE_SIZE; @SuppressWarnings("hiding") - protected static final int RECORD_SIZE = VALUE + Database.VALUE_SIZE; + protected static final int RECORD_SIZE = INTERNAL_TYPE + Database.TYPE_SIZE; - public PDOMCPPEnumerator(PDOMLinkage linkage, PDOMNode parent, IEnumerator enumerator) + public PDOMCPPEnumerator(PDOMLinkage linkage, PDOMNode parent, ICPPInternalEnumerator enumerator) throws CoreException { super(linkage, parent, enumerator.getNameCharArray()); - storeValue(enumerator); + IValue value= enumerator.getValue(); + if (value != null) { + linkage.storeValue(record + VALUE, value); + } + IType internalType = enumerator.getInternalType(); + if (internalType != null) { + linkage.storeType(record + INTERNAL_TYPE, internalType); + } } public PDOMCPPEnumerator(PDOMLinkage linkage, long record) { @@ -54,17 +64,14 @@ return IIndexCPPBindingConstants.CPPENUMERATOR; } - private void storeValue(IEnumerator enumerator) throws CoreException { - IValue value= enumerator.getValue(); - if (value != null) { - getLinkage().storeValue(record + VALUE, value); - } - } - @Override public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException { - if (newBinding instanceof IEnumerator) - storeValue((IEnumerator) newBinding); + if (newBinding instanceof IEnumerator) { + IValue value= ((IEnumerator) newBinding).getValue(); + if (value != null) { + getLinkage().storeValue(record + VALUE, value); + } + } } @Override @@ -74,7 +81,17 @@ return (IType) owner; return null; } - + + @Override + public IType getInternalType() { + try { + return getLinkage().loadType(record + INTERNAL_TYPE); + } catch (CoreException e) { + CCorePlugin.log(e); + } + return ProblemType.UNKNOWN_FOR_EXPRESSION; + } + @Override public IValue getValue() { try { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeratorSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeratorSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeratorSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeratorSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -16,7 +16,9 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; +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.ICPPInternalEnumerator; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.pdom.db.Database; @@ -30,14 +32,22 @@ */ class PDOMCPPEnumeratorSpecialization extends PDOMCPPSpecialization implements IPDOMCPPEnumerator { private static final int VALUE= PDOMCPPSpecialization.RECORD_SIZE; + private static final int INTERNAL_TYPE= VALUE + Database.VALUE_SIZE; @SuppressWarnings("hiding") - protected static final int RECORD_SIZE = VALUE + Database.VALUE_SIZE; + protected static final int RECORD_SIZE = INTERNAL_TYPE + Database.TYPE_SIZE; - public PDOMCPPEnumeratorSpecialization(PDOMLinkage linkage, PDOMNode parent, - IEnumerator enumerator, PDOMBinding specialized) throws CoreException { + public PDOMCPPEnumeratorSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, + ICPPInternalEnumerator enumerator, PDOMBinding specialized) throws CoreException { super(linkage, parent, (ICPPSpecialization) enumerator, specialized); - storeValue(enumerator); + IValue value= enumerator.getValue(); + if (value != null) { + getLinkage().storeValue(record + VALUE, value); + } + IType internalType = enumerator.getInternalType(); + if (internalType != null) { + linkage.storeType(record + INTERNAL_TYPE, internalType); + } } public PDOMCPPEnumeratorSpecialization(PDOMLinkage linkage, long record) { @@ -54,17 +64,14 @@ return IIndexCPPBindingConstants.CPP_ENUMERATOR_SPECIALIZATION; } - private void storeValue(IEnumerator enumerator) throws CoreException { - IValue value= enumerator.getValue(); - if (value != null) { - getLinkage().storeValue(record + VALUE, value); - } - } - @Override public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException { - if (newBinding instanceof IEnumerator) - storeValue((IEnumerator) newBinding); + if (newBinding instanceof IEnumerator) { + IValue value= ((IEnumerator) newBinding).getValue(); + if (value != null) { + getLinkage().storeValue(record + VALUE, value); + } + } } @Override @@ -76,6 +83,16 @@ } @Override + public IType getInternalType() { + try { + return getLinkage().loadType(record + INTERNAL_TYPE); + } catch (CoreException e) { + CCorePlugin.log(e); + } + return ProblemType.UNKNOWN_FOR_EXPRESSION; + } + + @Override public IValue getValue() { try { return getLinkage().loadValue(record + VALUE); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFieldSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFieldSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFieldSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFieldSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -38,7 +38,7 @@ @SuppressWarnings("hiding") protected static final int RECORD_SIZE = VALUE_OFFSET + Database.VALUE_SIZE; - public PDOMCPPFieldSpecialization(PDOMLinkage linkage, PDOMNode parent, + public PDOMCPPFieldSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPField field, PDOMBinding specialized) throws CoreException { super(linkage, parent, (ICPPSpecialization) field, specialized); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPGlobalScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPGlobalScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPGlobalScope.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPGlobalScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2015 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.pdom.dom.cpp; + +import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMGlobalScope; + +/** + * Represents the global C++ index scope. + */ +public class PDOMCPPGlobalScope extends PDOMGlobalScope implements ICPPNamespaceScope { + public static final PDOMCPPGlobalScope INSTANCE = new PDOMCPPGlobalScope(); + + private PDOMCPPGlobalScope() {} + + @Override + public void addUsingDirective(ICPPUsingDirective usingDirective) { + throw new UnsupportedOperationException(); + } + + @Override + public ICPPUsingDirective[] getUsingDirectives() { + return ICPPUsingDirective.EMPTY_ARRAY; + } + + @Override + public ICPPNamespaceScope[] getInlineNamespaces() { + return ICPPNamespaceScope.EMPTY_NAMESPACE_SCOPE_ARRAY; + } +} diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 QNX Software Systems and others. + * Copyright (c) 2005, 2014 QNX Software Systems 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 @@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IFunction; @@ -101,6 +102,7 @@ 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.ICPPEvaluation; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalEnumerator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary; @@ -120,6 +122,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnary; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnaryTypeID; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeOfDependentExpression; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeOfUnknownMember; import org.eclipse.cdt.internal.core.index.IIndexBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.composite.CompositeIndexBinding; @@ -133,6 +136,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMGlobalScope; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; @@ -324,6 +328,34 @@ fTemplate.initData(fOriginalAliasedType); } } + + class ConfigureInstance implements Runnable { + PDOMCPPSpecialization fInstance; + + public ConfigureInstance(PDOMCPPSpecialization specialization) { + fInstance = specialization; + postProcesses.add(this); + } + + @Override + public void run() { + fInstance.storeTemplateParameterMap(); + } + } + + class ConfigureClassInstance implements Runnable { + PDOMCPPClassInstance fClassInstance; + + public ConfigureClassInstance(PDOMCPPClassInstance classInstance) { + fClassInstance = classInstance; + postProcesses.add(this); + } + + @Override + public void run() { + fClassInstance.storeTemplateArguments(); + } + } /** * Adds or returns existing binding for the given name. @@ -336,13 +368,26 @@ IBinding binding = name.resolveBinding(); PDOMBinding pdomBinding = addBinding(binding, name); + + // Some nodes schedule some of their initialization to be done + // after the binding has been added to the PDOM, to avoid + // infinite recursion. We run those post-processes now. + // Note that we need to run it before addImplicitMethods() is + // called, since addImplicitMethods() expects the binding to + // be fully initialized. + handlePostProcesses(); + if (pdomBinding instanceof PDOMCPPClassType || pdomBinding instanceof PDOMCPPClassSpecialization) { if (binding instanceof ICPPClassType && name.isDefinition()) { addImplicitMethods(pdomBinding, (ICPPClassType) binding, name); } } - + + // Some of the nodes created during addImplicitMethods() can + // also schedule post-processes, so we need to run through + // them again. handlePostProcesses(); + return pdomBinding; } @@ -464,6 +509,13 @@ } else if (binding instanceof ICPPField) { if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) { pdomBinding = new PDOMCPPField(this, parent, (ICPPField) binding); + // If the field is inside an anonymous struct or union, add it to the parent node as well. + if (((ICompositeType) parent).isAnonymous()) { + parent2 = parent.getParentNode(); + if (parent2 == null) { + parent2 = this; + } + } } } else if (binding instanceof ICPPClassTemplate) { pdomBinding= new PDOMCPPClassTemplate(this, parent, (ICPPClassTemplate) binding); @@ -498,9 +550,9 @@ pdomBinding = new PDOMCPPUsingDeclaration(this, parent, (ICPPUsingDeclaration) binding); } else if (binding instanceof ICPPEnumeration) { pdomBinding = new PDOMCPPEnumeration(this, parent, (ICPPEnumeration) binding); - } else if (binding instanceof IEnumerator) { + } else if (binding instanceof ICPPInternalEnumerator) { assert parent instanceof ICPPEnumeration; - pdomBinding = new PDOMCPPEnumerator(this, parent, (IEnumerator) binding); + pdomBinding = new PDOMCPPEnumerator(this, parent, (ICPPInternalEnumerator) binding); if (parent instanceof ICPPEnumeration && !((ICPPEnumeration) parent).isScoped()) { parent2= parent.getParentNode(); if (parent2 == null) { @@ -632,8 +684,8 @@ result= new PDOMCPPUsingDeclarationSpecialization(this, parent, (ICPPUsingDeclaration) special, orig); } else if (special instanceof ICPPEnumeration) { result= new PDOMCPPEnumerationSpecialization(this, parent, (ICPPEnumeration) special, orig); - } else if (special instanceof IEnumerator) { - result= new PDOMCPPEnumeratorSpecialization(this, parent, (IEnumerator) special, orig); + } else if (special instanceof ICPPInternalEnumerator) { + result= new PDOMCPPEnumeratorSpecialization(this, parent, (ICPPInternalEnumerator) special, orig); } return result; @@ -644,7 +696,7 @@ final long fileLocalRec= type.getLocalToFileRec(); IScope scope = binding.getCompositeScope(); if (scope instanceof ICPPClassScope) { - List old= new ArrayList(); + List old= new ArrayList<>(); if (type instanceof ICPPClassType) { ArrayUtil.addAll(old, ClassTypeHelper.getImplicitMethods((ICPPClassType) type, point)); } @@ -1004,6 +1056,11 @@ } @Override + public PDOMGlobalScope getGlobalScope() { + return PDOMCPPGlobalScope.INSTANCE; + } + + @Override public void onCreateName(PDOMFile file, IASTName name, PDOMName pdomName) throws CoreException { super.onCreateName(file, name, pdomName); @@ -1225,6 +1282,8 @@ return CPPAliasTemplateInstance.unmarshal(firstBytes, buffer); case ITypeMarshalBuffer.TYPE_TRANSFORMATION: return CPPUnaryTypeTransformation.unmarshal(firstBytes, buffer); + case ITypeMarshalBuffer.UNKNOWN_MEMBER_TYPE: + return TypeOfUnknownMember.unmarshal(getPDOM(), firstBytes, buffer); } throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first bytes=" + firstBytes)); //$NON-NLS-1$ diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -45,7 +45,7 @@ fType= t; } - public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam, + public PDOMCPPParameterSpecialization(PDOMCPPLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam, PDOMCPPParameter original, PDOMCPPParameterSpecialization next) throws CoreException { super(linkage, parent, (ICPPSpecialization) astParam, original); fType= null; // This constructor is used for adding parameters to the database, only. diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -43,15 +43,20 @@ private volatile IBinding fSpecializedCache= null; private volatile ICPPTemplateParameterMap fArgMap; - public PDOMCPPSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPSpecialization spec, + public PDOMCPPSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPSpecialization spec, IPDOMBinding specialized) throws CoreException { super(linkage, parent, spec.getNameCharArray()); getDB().putRecPtr(record + SPECIALIZED, specialized.getRecord()); // Specializations that are not instances have the same map as their owner. if (this instanceof ICPPTemplateInstance) { - long rec= PDOMCPPTemplateParameterMap.putMap(this, spec.getTemplateParameterMap()); - getDB().putRecPtr(record + ARGMAP, rec); + // Defer storing of template parameter map to the post-process + // to avoid infinite recursion when the evaluation of a non-type + // template argument tries to store its template definition. + // Until the post-process runs, temporarily store the input (possibly + // non-PDOM) map. + fArgMap = spec.getTemplateParameterMap(); + linkage.new ConfigureInstance(this); } try { Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(spec); @@ -107,6 +112,22 @@ return fArgMap; } + public void storeTemplateParameterMap() { + try { + // fArgMap here is the temporarily stored, possibly non-PDOM + // map stored by the constructor. Construct the PDOM map and + // store it. + long rec= PDOMCPPTemplateParameterMap.putMap(this, fArgMap); + getDB().putRecPtr(record + ARGMAP, rec); + + // Read the stored map next time getTemplateParameterMap() + // is called. + fArgMap = null; + } catch (CoreException e) { + CCorePlugin.log(e); + } + } + @Override public int getSignatureHash() throws CoreException { return getDB().getInt(record + SIGNATURE_HASH); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedefSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedefSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedefSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedefSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -33,7 +33,7 @@ @SuppressWarnings("hiding") protected static final int RECORD_SIZE = TYPE_OFFSET + Database.TYPE_SIZE; - public PDOMCPPTypedefSpecialization(PDOMLinkage linkage, PDOMNode parent, ITypedef typedef, PDOMBinding specialized) + public PDOMCPPTypedefSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ITypedef typedef, PDOMBinding specialized) throws CoreException { super(linkage, parent, (ICPPSpecialization) typedef, specialized); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java 2015-02-11 19:19:10.000000000 +0000 @@ -36,7 +36,7 @@ private volatile IBinding[] delegates; - public PDOMCPPUsingDeclarationSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPUsingDeclaration using, PDOMBinding specialized) + public PDOMCPPUsingDeclarationSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPUsingDeclaration using, PDOMBinding specialized) throws CoreException { super(linkage, parent, (ICPPSpecialization) using, specialized); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDirective.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDirective.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDirective.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDirective.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2015 Wind River Systems, 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 @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -86,7 +87,7 @@ } catch (CoreException e) { CCorePlugin.log(e); } - return null; + return PDOMCPPGlobalScope.INSTANCE; } @Override @@ -116,4 +117,9 @@ public void delete(PDOMLinkage linkage) throws CoreException { fLinkage.getDB().free(fRecord); } + + @Override + public String toString() { + return "using namespace " + getNominatedScope(); //$NON-NLS-1$ + } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java 2015-02-11 19:19:10.000000000 +0000 @@ -142,7 +142,7 @@ } @Override - public ASTNodeProperty getPropertyInParent() { + public final ASTNodeProperty getPropertyInParent() { return fDelegate.getPropertyInParent(); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 QNX Software Systems and others. + * Copyright (c) 2005, 2015 QNX Software Systems 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 @@ -9,6 +9,7 @@ * Doug Schaefer (QNX) - Initial API and implementation * Markus Schorn (Wind River Systems) * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom; @@ -17,19 +18,15 @@ import org.eclipse.cdt.core.CCorePlugin; 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.IFunction; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IScope.ScopeLookupData; import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; import org.eclipse.cdt.core.dom.ast.tag.ITagReader; import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.parser.util.CharArrayUtils; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBindingComparator; @@ -55,6 +52,7 @@ @SuppressWarnings("hiding") protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 20; + private byte hasDeclaration= -1; protected PDOMBinding(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException { @@ -255,39 +253,24 @@ if (parent instanceof IIndexScope) { return (IIndexScope) parent; } - } catch (CoreException ce) { - CCorePlugin.log(ce); + } catch (CoreException e) { + CCorePlugin.log(e); } - return null; + return getLinkage().getGlobalScope(); } @Override - public final IIndexScope getScope() { + public IIndexScope getScope() { // The parent node in the binding hierarchy is the scope. try { IBinding parent= getParentBinding(); - while (parent != null) { - if (parent instanceof ICPPClassType) { - return (IIndexScope) ((ICPPClassType) parent).getCompositeScope(); - } else if (parent instanceof ICPPUnknownBinding) { - return (IIndexScope) ((ICPPUnknownBinding) parent).asScope(); - } else if (parent instanceof ICPPEnumeration) { - final ICPPEnumeration enumeration = (ICPPEnumeration) parent; - if (enumeration.isScoped()) { - return (IIndexScope) enumeration.asScope(); - } - parent= ((PDOMNamedNode) parent).getParentBinding(); - } else if (parent instanceof IIndexScope) { - return (IIndexScope) parent; - } else { - return null; - } + if (parent instanceof IIndexScope) { + return (IIndexScope) parent; } - } catch (DOMException e) { - } catch (CoreException ce) { - CCorePlugin.log(ce); + } catch (CoreException e) { + CCorePlugin.log(e); } - return null; + return getLinkage().getGlobalScope(); } @Override diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMGlobalScope.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMGlobalScope.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMGlobalScope.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMGlobalScope.java 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2015 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.pdom.dom; + +import org.eclipse.cdt.core.dom.ast.EScopeKind; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.index.IIndexBinding; +import org.eclipse.cdt.core.index.IIndexFileSet; +import org.eclipse.cdt.core.index.IIndexName; +import org.eclipse.cdt.internal.core.index.IIndexScope; + +/** + * Base class for C and C++ global index scopes. + */ +public abstract class PDOMGlobalScope implements IIndexScope { + @Override + public EScopeKind getKind() { + return EScopeKind.eGlobal; + } + + @Override + public IBinding[] find(String name) { + throw new UnsupportedOperationException(); + } + + @Override + public IBinding getBinding(IASTName name, boolean resolve) { + throw new UnsupportedOperationException(); + } + + @Override + public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) { + throw new UnsupportedOperationException(); + } + + @Override + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup) { + throw new UnsupportedOperationException(); + } + + @Override + public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, + IIndexFileSet acceptLocalBindings) { + throw new UnsupportedOperationException(); + } + + @Override + public IBinding[] getBindings(ScopeLookupData lookup) { + throw new UnsupportedOperationException(); + } + + @Override + public IIndexBinding getScopeBinding() { + return null; + } + + @Override + public IIndexScope getParent() { + return null; + } + + @Override + public IIndexName getScopeName() { + return null; + } + + @Override + public String toString() { + return ""; //$NON-NLS-1$ + } +} diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java 2015-02-11 19:19:10.000000000 +0000 @@ -180,10 +180,12 @@ return null; } - abstract public PDOMNode getNode(long record, int nodeType) throws CoreException; + public abstract PDOMNode getNode(long record, int nodeType) throws CoreException; public abstract IBTreeComparator getIndexComparator(); + public abstract PDOMGlobalScope getGlobalScope(); + public IBTreeComparator getNestedBindingsComparator() { return new FindBinding.NestedBindingsBTreeComparator(this); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMIndexerJob.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMIndexerJob.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMIndexerJob.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMIndexerJob.java 2015-02-11 19:19:10.000000000 +0000 @@ -30,7 +30,7 @@ * Job updating the progress monitor of the indexer job. */ final class ProgressUpdateJob extends Job { - private boolean fStopped; + private boolean fCancelled; private ProgressUpdateJob() { super(CCorePlugin.getResourceString("PDOMIndexerJob.updateMonitorJob")); //$NON-NLS-1$ @@ -40,16 +40,28 @@ @Override protected IStatus run(IProgressMonitor m) { int currentTick= 0; - while (!fStopped && !m.isCanceled()) { + while (!fCancelled && !m.isCanceled()) { currentTick= pdomManager.getMonitorMessage(PDOMIndexerJob.this, currentTick, TOTAL_MONITOR_WORK); try { - Thread.sleep(PROGRESS_UPDATE_INTERVAL); + synchronized(this) { + if (fCancelled) + break; + wait(PROGRESS_UPDATE_INTERVAL); + } } catch (InterruptedException e) { return Status.CANCEL_STATUS; } } return Status.OK_STATUS; } + @Override + protected void canceling() { + // Speed up cancellation by notifying the waiting thread. + synchronized(this) { + fCancelled= true; + notify(); + } + } } private static final int PROGRESS_UPDATE_INTERVAL = 500; @@ -59,7 +71,7 @@ private final PDOMManager pdomManager; private IPDOMIndexerTask currentTask; private boolean cancelledByManager= false; - private Object taskMutex = new Object(); + private final Object taskMutex = new Object(); private IProgressMonitor fMonitor; private final boolean fShowActivity; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java 2015-02-11 19:19:10.000000000 +0000 @@ -251,11 +251,16 @@ * CDT 8.4 development (versions not supported on the 8.3.x branch) * 170.0 - Unconditionally store arguments of EvalTypeId, bug 430230. * 171.0 - Replacement headers for Organize Includes, bug 414692. - * 172.0 - Store default values for function parameters, bug 432701. + * #172.0# - Store default values for function parameters, bug 432701. <> + * + * CDT 8.6 development (versions not supported on the 8.5.x branch) + * 180.0 - Internal types of enumerators, bug 446711. + * 180.1 - Storing types of unknown members, bug 447728. + * 180.2 - Do not apply significant macros to source files, bug 450888. */ - private static final int MIN_SUPPORTED_VERSION= version(172, 0); - private static final int MAX_SUPPORTED_VERSION= version(172, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(172, 0); + private static final int MIN_SUPPORTED_VERSION= version(180, 2); + private static final int MAX_SUPPORTED_VERSION= version(180, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(180, 2); private static int version(int major, int minor) { return (major << 16) + minor; @@ -968,7 +973,6 @@ @Override public void releaseReadLock() { - boolean clearCache= false; synchronized (mutex) { assert lockCount > 0: "No lock to release"; //$NON-NLS-1$ if (sDEBUG_LOCKS) { @@ -979,12 +983,15 @@ if (lockCount > 0) --lockCount; mutex.notifyAll(); - clearCache= lockCount == 0; db.setLocked(lockCount != 0); } - if (clearCache) { - clearResultCache(); - } + // A lock release probably means that some AST is going away. The result cache has to be + // cleared since it may contain objects belonging to the AST that is going away. A failure + // to release an AST object would cause a memory leak since the whole AST would remain + // pinned to memory. + // TODO(sprigogin): It would be more efficient to replace the global result cache with + // separate caches for each AST. + clearResultCache(); } /** diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java 2015-02-11 19:19:10.000000000 +0000 @@ -413,8 +413,7 @@ return LanguageManager.getInstance().getPDOMLinkageFactoryMappings(); } - private void storeDatabaseName(IProject rproject, String dbName) - throws CoreException { + private void storeDatabaseName(IProject rproject, String dbName) throws CoreException { rproject.setPersistentProperty(dbNameProperty, dbName); } @@ -838,7 +837,7 @@ IPDOMIndexer indexer; synchronized (fUpdatePolicies) { - // Prevent recreating the indexer + // Prevent recreating the indexer. fClosingProjects.add(name); indexer= getIndexer(cproject); } @@ -850,7 +849,7 @@ Object pdom= null; synchronized (fProjectToPDOM) { pdom = fProjectToPDOM.remove(rproject); - // if the project is closed allow to reuse the pdom. + // If the project is closed allow to reuse the pdom. if (pdom instanceof WritablePDOM && !delete) { fFileToProject.remove(((WritablePDOM) pdom).getDB().getLocation()); } @@ -1264,7 +1263,8 @@ } // Overwrite internal location representations. - final WritablePDOM newPDOM = new WritablePDOM(targetLocation, pdom.getLocationConverter(), getLinkageFactories()); + final WritablePDOM newPDOM = + new WritablePDOM(targetLocation, pdom.getLocationConverter(), getLinkageFactories()); newPDOM.acquireWriteLock(null); try { newPDOM.rewriteLocations(newConverter); @@ -1290,24 +1290,27 @@ * @throws OperationCanceledException in case the thread was interrupted * @since 4.0 */ - public void importProjectPDOM(ICProject project, InputStream stream, IProgressMonitor monitor) throws CoreException, IOException { + public void importProjectPDOM(ICProject project, InputStream stream, IProgressMonitor monitor) + throws CoreException, IOException { // make a copy of the database String newName= createNewDatabaseName(project); File newFile= fileFromDatabaseName(newName); OutputStream out= new FileOutputStream(newFile); try { int version= 0; - for (int i=0; i<4; i++) { + for (int i= 0; i < 4; i++) { byte b= (byte) stream.read(); version= (version << 8) + (b & 0xff); out.write(b); } if (version > PDOM.getMaxSupportedVersion()) { - final IStatus status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, 0, CCorePlugin.getResourceString("PDOMManager.unsupportedHigherVersion"), null); //$NON-NLS-1$ + final IStatus status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, 0, + CCorePlugin.getResourceString("PDOMManager.unsupportedHigherVersion"), null); //$NON-NLS-1$ throw new CoreException(status); } - if ( !PDOM.isSupportedVersion( version ) ) { - final IStatus status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, 0, CCorePlugin.getResourceString("PDOMManager.unsupportedVersion"), null); //$NON-NLS-1$ + if (!PDOM.isSupportedVersion(version)) { + final IStatus status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, 0, + CCorePlugin.getResourceString("PDOMManager.unsupportedVersion"), null); //$NON-NLS-1$ throw new CoreException(status); } byte[] buffer= new byte[2048]; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java 2015-02-11 19:19:10.000000000 +0000 @@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexInclude; @@ -268,7 +267,7 @@ /** * Returns the best file for the given location, linkage, and translation unit. - * May return null, if no such file exists. + * May return {@code null}, if no such file exists. * * The "best" file (variant) is the one with the most content, as measured * by the total number of macros defined in the file. The rationale is that @@ -281,7 +280,7 @@ * @param linkageID the id of the linkage in which the file has been parsed. * @param location the IIndexFileLocation representing the location of the file * @param tu the translation unit from which 'location' originates - * @return the best file for the location, or null if the file is not + * @return the best file for the location, or {@code null} if the file is not * present in the index * @throws CoreException */ @@ -305,7 +304,8 @@ if (fPathResolver != null && node != null) { IASTFileLocation loc= node.getFileLocation(); if (loc != null) { - ISignificantMacros sigMacros= getSignificantMacros(node, loc); + IASTPreprocessorIncludeStatement owner= loc.getContextInclusionStatement(); + ISignificantMacros sigMacros= owner != null ? owner.getSignificantMacros() : ISignificantMacros.NONE; if (sigMacros != null) { IIndexFileLocation location = fPathResolver.resolveASTPath(loc.getFileName()); if (uncommittedKey != null && uncommittedKey.equals(new FileContentKey(linkageID, location, sigMacros))) @@ -317,18 +317,6 @@ return null; } - private ISignificantMacros getSignificantMacros(IASTNode node, IASTFileLocation loc) throws CoreException { - IASTPreprocessorIncludeStatement owner= loc.getContextInclusionStatement(); - if (owner != null) - return owner.getSignificantMacros(); - - IASTTranslationUnit tu = node.getTranslationUnit(); - if (tu != null) - return tu.getSignificantMacros(); - - return null; - } - @Override public boolean hasLastingDefinition(PDOMBinding binding) throws CoreException { if (fileBeingUpdated == null) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,11 +7,11 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml - 5.8.0-SNAPSHOT + 5.9.1-SNAPSHOT org.eclipse.cdt.core eclipse-plugin diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/schema/ProblemMarkerFilter.exsd eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/schema/ProblemMarkerFilter.exsd --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/schema/ProblemMarkerFilter.exsd 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/schema/ProblemMarkerFilter.exsd 2015-02-11 19:19:10.000000000 +0000 @@ -9,9 +9,9 @@ This extension point allows to filter out unneeded problem markers. For example during building of Qt base project with QML files tool Qt Linguist could report syntax errors in some qml file. These errors are presented as - "C/C++ Problems" in qml files because they match format CDT expects for errors. + "C/C++ Problems" in qml files because they match format CDT expects for errors. If there is already installed plug-in that handles QML files it is a wise to ignore such - errors because they are already reported as "QML Problems" with more meaningful descriptions. + errors because they are already reported as "QML Problems" with more meaningful descriptions. @@ -53,7 +53,7 @@ - + @@ -64,9 +64,9 @@ Implementation of Problem Marker Filter that allows to filter out unneded or duplicit problem markers. - + - + @@ -86,7 +86,7 @@ - The following is an example of a qmakeEnvProvider contribution: + The following is an example of a qmakeEnvProvider contribution: <p> <pre> <extension @@ -114,7 +114,7 @@ - The contributed class must implement <code>org.eclipse.cdt.core.IProblemMarkerFilter</code>. + The contributed class must implement <code>org.eclipse.cdt.core.IProblemMarkerFilter</code>. @@ -123,7 +123,7 @@ - Copyright (c) 2014 BlackBerry Limited and others. + Copyright (c) 2014 BlackBerry Limited 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 diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java 2015-02-11 19:19:10.000000000 +0000 @@ -1209,7 +1209,7 @@ } /** - * this method is a full equivalent to createProjectDescription(IProject, boolean, false). + * Equivalent to createProjectDescription(IProject, boolean, false). * * @see #createProjectDescription(IProject, boolean, boolean) */ @@ -1218,17 +1218,21 @@ } /** - * the method creates and returns a writable project description + * Creates and returns a writable project description. * * @param project project for which the project description is requested * @param loadIfExists if true the method first tries to load and return the project description - * from the settings file (.cproject) - * if false, the stored settings are ignored and the new (empty) project description is created - * @param creating if true the created project description will be contain the true "isCdtProjectCreating" state. - * NOTE: in case the project already contains the project description AND its "isCdtProjectCreating" is false - * the resulting description will be created with the false "isCdtProjectCreating" state + * from the settings file (.cproject), + * if false, the stored settings are ignored and the new (empty) project description is + * created + * @param creating if true the created project description will be contain the true + * "isCdtProjectCreating" state. + *
NOTE: in case the project already contains the project description AND its + * "isCdtProjectCreating" is false the resulting description will be created with the false + * "isCdtProjectCreating" state. * - * NOTE: changes made to the returned project description will not be applied until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called + *
NOTE: changes made to the returned project description will not be applied until + * the {@link #setProjectDescription(IProject, ICProjectDescription)} is called. * @return {@link ICProjectDescription} * @throws CoreException */ @@ -1237,16 +1241,17 @@ } /** - * returns the project description associated with this project or null if the project does not contain the - * CDT data associated with it. + * Returns the project description associated with this project or null if the project does not + * contain the CDT data associated with it. + * + * This is a convenience method fully equivalent to getProjectDescription(project, true) + * see {@link #getProjectDescription(IProject, boolean)} for more detail. * - * this is a convenience method fully equivalent to getProjectDescription(project, true) - * see {@link #getProjectDescription(IProject, boolean)} for more detail * @param project - * @return a writable copy of the ICProjectDescription or null if the project does not contain the - * CDT data associated with it. - * Note: changes to the project description will not be reflected/used by the core - * until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called + * @return a writable copy of the ICProjectDescription or null if the project does not contain + * the CDT data associated with it. + *
Note: changes to the project description will not be reflected/used by the core + * until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called. * * @see #getProjectDescription(IProject, boolean) */ @@ -1255,9 +1260,10 @@ } /** - * this method is called to save/apply the project description - * the method should be called to apply changes made to the project description - * returned by the {@link #getProjectDescription(IProject, boolean)} or {@link #createProjectDescription(IProject, boolean)} + * Called to save/apply the project description. + * The method should be called to apply changes made to the project description + * returned by the {@link #getProjectDescription(IProject, boolean)} or + * {@link #createProjectDescription(IProject, boolean)} * * @param project * @param des @@ -1275,28 +1281,29 @@ } /** - * returns the project description associated with this project or null if the project does not contain the - * CDT data associated with it. + * Returns the project description associated with this project or null if the project + * does not contain the CDT data associated with it. * * @param project project for which the description is requested * @param write if true, the writable description copy is returned. - * If false the cached read-only description is returned. + * If false the cached read-only description is returned. * - * CDT core maintains the cached project description settings. If only read access is needed to description, - * then the read-only project description should be obtained. - * This description always operates with cached data and thus it is better to use it for performance reasons - * All set* calls to the read-only description result in the {@link WriteAccessException} + *
CDT core maintains the cached project description settings. If only read access is needed + * to description, then the read-only project description should be obtained. + * This description always operates with cached data and thus it is better to use it for + * performance reasons. All set* calls to the read-only description result in + * the {@link WriteAccessException}. * - * When the writable description is requested, the description copy is created. - * Changes to this description will not be reflected/used by the core and Build System untill the - * {@link #setProjectDescription(IProject, ICProjectDescription)} is called + * When the writable description is requested, the description copy is created. Changes to this + * description will not be reflected/used by the core and the Build System until the + * {@link #setProjectDescription(IProject, ICProjectDescription)} is called. * - * Each getProjectDescription(project, true) returns a new copy of the project description + * Each getProjectDescription(project, true) returns a new copy of the project description. * - * The writable description uses the cached data untill the first set call + * The writable description uses the cached data until the first set call * after that the description communicates directly to the Build System * i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension - * This ensures the Core<->Build System settings integrity + * This ensures the Core<->Build System settings integrity. * * @return {@link ICProjectDescription} or null if the project does not contain the * CDT data associated with it. @@ -1306,11 +1313,9 @@ } /** - * forces the cached data of the specified projects to be re-calculated. - * if the projects argument is null al projects - * within the workspace are updated + * Forces the cached data of the specified projects to be re-calculated. * - * @param projects + * @param projects if null, all projects within the workspace are updated * @param monitor * @throws CoreException */ @@ -1319,7 +1324,8 @@ } /** - * Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven + * Answers whether the given project is a new-style project, i.e. + * CConfigurationDataProvider-driven. */ public boolean isNewStyleProject(IProject project) { return fNewCProjectDescriptionManager.isNewStyleProject(project); @@ -1361,7 +1367,7 @@ } /** - * Print a message in the log + * Prints a message in the log * * @param severity - desired severity of the message in the log, * one of {@link IStatus#INFO}, {@link IStatus#WARNING} or {@link IStatus#ERROR} @@ -1375,7 +1381,7 @@ } /** - * Print a message in the log accompanied by stack trace + * Prints a message in the log accompanied by stack trace * * @param severity - desired severity of the message in the log, * one of {@link IStatus#INFO}, {@link IStatus#WARNING} or {@link IStatus#ERROR} @@ -1406,7 +1412,7 @@ public static void log(String message, Throwable e) { Throwable nestedException; if (e instanceof CModelException - && (nestedException = ((CModelException)e).getException()) != null) { + && (nestedException = ((CModelException) e).getException()) != null) { e = nestedException; } log(createStatus(message, e)); @@ -1443,7 +1449,7 @@ } /** - * Returns preference controlling whether source roots are shown at the top of projects + * Returns the preference controlling whether source roots are shown at the top of projects * or embedded within the resource tree of projects when they are not top level folders. * * @return boolean preference value diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 QNX Software Systems and others. + * Copyright (c) 2000, 2015 QNX Software Systems 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 @@ -235,6 +235,22 @@ public static final String INCLUDE_PRIVATE_PATTERN = "includes.privatePattern"; //$NON-NLS-1$ /** + * Default value for {@link #INCLUDE_KEEP_PATTERN}. + * @since 5.9 + */ + public static final String DEFAULT_INCLUDE_KEEP_PATTERN = "IWYU\\s+(pragma:?\\s+)?keep"; //$NON-NLS-1$ + + /** + * Preference key for the regular expression pattern that, when appears in a comment on the same + * line as include statement, indicates that the include statement should be preserved when + * organizing includes. + * @see "https://code.google.com/p/include-what-you-use/wiki/IWYUPragmas" + * + * @since 5.9 + */ + public static final String INCLUDE_KEEP_PATTERN = "includes.keepPattern"; //$NON-NLS-1$ + + /** * A named preference that controls whether the parser should skip trivial expressions in initializer lists. *

* Value is of type Boolean. @@ -301,17 +317,31 @@ /** * Returns the node in the preference in the given context. + * + * @param key The preference key. + * @param cProject The current context or {@code null} if no context is available and + * the workspace setting should be taken. Note that passing {@code null} should + * be avoided. + * @return Returns the node matching the given context. + */ + private static IEclipsePreferences getPreferenceNode(String key, ICProject cProject) { + IProject project = cProject == null ? null : cProject.getProject(); + return getPreferenceNode(key, project); + } + + /** + * Returns the node in the preference in the given context. + * * @param key The preference key. * @param project The current context or {@code null} if no context is available and * the workspace setting should be taken. Note that passing {@code null} should * be avoided. * @return Returns the node matching the given context. */ - private static IEclipsePreferences getPreferenceNode(String key, ICProject project) { + private static IEclipsePreferences getPreferenceNode(String key, IProject project) { IEclipsePreferences node = null; - if (project != null) { - node = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID); + node = new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID); if (node.get(key, null) != null) { return node; } @@ -331,6 +361,7 @@ /** * Returns the string value for the given key in the given context. + * * @param key The preference key * @param project The current context or {@code null} if no context is available and * the workspace setting should be taken. Note that passing {@code null} should be avoided. @@ -343,6 +374,20 @@ /** * Returns the string value for the given key in the given context. + * + * @param key The preference key + * @param project The current context or {@code null} if no context is available and + * the workspace setting should be taken. Note that passing {@code null} should be avoided. + * @return Returns the current value for the string. + * @since 5.9 + */ + public static String getPreference(String key, IProject project) { + return getPreference(key, project, null); + } + + /** + * Returns the string value for the given key in the given context. + * * @param key The preference key * @param project The current context or {@code null} if no context is available and * the workspace setting should be taken. Note that passing {@code null} should be avoided. @@ -355,7 +400,22 @@ } /** + * Returns the string value for the given key in the given context. + * + * @param key The preference key + * @param project The current context or {@code null} if no context is available and + * the workspace setting should be taken. Note that passing {@code null} should be avoided. + * @param defaultValue The default value if not specified in the preferences. + * @return Returns the current value of the preference. + * @since 5.9 + */ + public static String getPreference(String key, IProject project, String defaultValue) { + return getPreferenceNode(key, project).get(key, defaultValue); + } + + /** * Returns the integer value for the given key in the given context. + * * @param key The preference key * @param project The current context or {@code null} if no context is available and * the workspace setting should be taken. Note that passing {@code null} should be avoided. @@ -368,7 +428,22 @@ } /** + * Returns the integer value for the given key in the given context. + * + * @param key The preference key + * @param project The current context or {@code null} if no context is available and + * the workspace setting should be taken. Note that passing {@code null} should be avoided. + * @param defaultValue The default value if not specified in the preferences. + * @return Returns the current value of the preference. + * @since 5.9 + */ + public static int getPreference(String key, IProject project, int defaultValue) { + return getPreferenceNode(key, project).getInt(key, defaultValue); + } + + /** * Returns the boolean value for the given key in the given context. + * * @param key The preference key * @param project The current context or {@code null} if no context is available and * the workspace setting should be taken. Note that passing {@code null} should be avoided. @@ -380,6 +455,20 @@ return getPreferenceNode(key, project).getBoolean(key, defaultValue); } + /** + * Returns the boolean value for the given key in the given context. + * + * @param key The preference key + * @param project The current context or {@code null} if no context is available and + * the workspace setting should be taken. Note that passing {@code null} should be avoided. + * @param defaultValue The default value if not specified in the preferences. + * @return Returns the current value of the preference. + * @since 5.9 + */ + public static boolean getPreference(String key, IProject project, boolean defaultValue) { + return getPreferenceNode(key, project).getBoolean(key, defaultValue); + } + /** * Returns the scopes for preference lookup. * diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 QNX Software Systems and others. + * Copyright (c) 2000, 2014 QNX Software Systems 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 @@ -9,6 +9,7 @@ * QNX Software Systems - Initial API and implementation * Sergey Prigogin (Google) * Anton Leherbauer (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.formatter; @@ -57,6 +58,18 @@ /** *

+	 * FORMATTER / Option that tells the formatter that the formatting region should be
+	 * extended to the enclosing statement boundaries.
+	 *     - option id:         "org.eclipse.cdt.core.formatter.statement_scope"
+	 *     - possible values:   object of class {@link Boolean} or {@code null} 
+	 *     - default:           null
+	 * 
+ * @since 5.9 + */ + public static final String FORMATTER_STATEMENT_SCOPE = CCorePlugin.PLUGIN_ID + ".formatter.statement_scope"; //$NON-NLS-1$ + + /** + *
 	 * FORMATTER / Value to set a brace location at the end of a line.
 	 * 
* @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 QNX Software Systems and others. + * Copyright (c) 2000, 2015 QNX Software Systems 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 @@ -68,6 +68,7 @@ defaultPreferences.put(CCorePreferenceConstants.INCLUDE_BEGIN_EXPORTS_PATTERN, CCorePreferenceConstants.DEFAULT_INCLUDE_BEGIN_EXPORTS_PATTERN); defaultPreferences.put(CCorePreferenceConstants.INCLUDE_END_EXPORTS_PATTERN, CCorePreferenceConstants.DEFAULT_INCLUDE_END_EXPORTS_PATTERN); defaultPreferences.put(CCorePreferenceConstants.INCLUDE_PRIVATE_PATTERN, CCorePreferenceConstants.DEFAULT_INCLUDE_PRIVATE_PATTERN); + defaultPreferences.put(CCorePreferenceConstants.INCLUDE_KEEP_PATTERN, CCorePreferenceConstants.DEFAULT_INCLUDE_KEEP_PATTERN); // Scalability defaults. defaultPreferences.putBoolean(CCorePreferenceConstants.SCALABILITY_SKIP_TRIVIAL_EXPRESSIONS, CCorePreferenceConstants.DEFAULT_SCALABILITY_SKIP_TRIVIAL_EXPRESSIONS); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerChain.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerChain.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerChain.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerChain.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,18 +1,18 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2014 Wind River Systems, 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: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.Iterator; -import java.util.LinkedList; -import java.util.ListIterator; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; @@ -26,7 +26,7 @@ private static final int MAX_DEPTH = 100; // 100 saves private static final long MAX_AGE = 24 * 60 * 60 * 1000; // one day - private LinkedList fTrackers= new LinkedList(); + private Deque fTrackers= new ArrayDeque<>(); private PositionTracker fActiveTracker; private IDocument fDocument; @@ -35,13 +35,12 @@ } public int createCheckpoint(long timestamp) { - // travel in time + // Travel in time. while (fActiveTracker != null && fActiveTracker.getTimeStamp() >= timestamp) { fTrackers.removeLast(); if (fTrackers.isEmpty()) { fActiveTracker= null; - } - else { + } else { fActiveTracker= fTrackers.getLast(); fActiveTracker.revive(); } @@ -76,7 +75,7 @@ } /* (non-Javadoc) - * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent) + * @see org.eclipse.jface.text.IPositionUpdater#update(DocumentEvent) */ private void update(DocumentEvent event) { String text = event.getText(); @@ -93,19 +92,19 @@ } /** - * Find the nearest tracker created at or after the given time. + * Finds the nearest tracker created at or after the given time. + * * @param timestamp in milliseconds. * @return the tracker nearest to the timestamp, null if all were created before. */ public PositionTracker findTrackerAtOrAfter(long timestamp) { PositionTracker candidate= null; - for (ListIterator iter = fTrackers.listIterator(fTrackers.size()); iter.hasPrevious();) { - PositionTracker tracker = iter.previous(); + for (Iterator iter = fTrackers.descendingIterator(); iter.hasNext();) { + PositionTracker tracker = iter.next(); long trackerTimestamp= tracker.getTimeStamp(); if (trackerTimestamp >= timestamp) { candidate= tracker; - } - else { + } else { break; } } @@ -113,13 +112,14 @@ } /** - * Find the tracker created at the given time. + * Finds the tracker created at the given time. + * * @param timestamp in milliseconds. * @return the tracker at the timestamp, null if none created at the given time. */ public PositionTracker findTrackerAt(long timestamp) { - for (ListIterator iter = fTrackers.listIterator(fTrackers.size()); iter.hasPrevious();) { - PositionTracker tracker = iter.previous(); + for (Iterator iter = fTrackers.descendingIterator(); iter.hasNext();) { + PositionTracker tracker = iter.next(); long trackerTimestamp= tracker.getTimeStamp(); if (trackerTimestamp == timestamp) { return tracker; @@ -132,7 +132,7 @@ } /** - * Destroy the tracker. + * Destroys the tracker. */ public void dispose() { stopTracking(); @@ -162,7 +162,7 @@ @Override public void documentChanged(DocumentEvent event) { - // react before updateing the document + // React before updating the document. } public IDocument getCurrentDocument() { @@ -180,8 +180,8 @@ public int getMemorySize() { int size= MEMORY_SIZE; for (PositionTracker tracker : fTrackers) { - size+= LINKED_LIST_ENTRY_SIZE; - size+= tracker.getMemorySize(); + size += LINKED_LIST_ENTRY_SIZE; + size += tracker.getMemorySize(); } return size; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTracker.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTracker.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTracker.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTracker.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core; import java.io.PrintStream; @@ -38,7 +37,7 @@ } /** - * Undo the retirement to make this the head of a tracker chain again. + * Undoes the retirement to make this the head of a tracker chain again. */ synchronized void revive() { fFollowedBy = null; @@ -47,6 +46,7 @@ /** * Notifies the tracker of the insertion of characters. * It is assumed that character get inserted before the offset. + * * @param offset offset of the character in front of which insertion occurs. * @param count amount of characters inserted. */ @@ -63,6 +63,7 @@ * Notifies the tracker of the removal of characters. * delete(0,1) removes the first character, * for convenience delete(1,-1) does the same. + * * @param offset offset of the first character deleted. * @param count amount of characters deleted. */ @@ -71,8 +72,7 @@ assert offset >= 0; if (count < 0) { delete(offset + count, -count); - } - else { + } else { if (count == 0 || offset < 0) { return; } @@ -82,6 +82,7 @@ /** * Calculates the position in the original unmodified text. + * * @param currentOffset position in the modified text. * @return position in the unmodified text. */ @@ -100,6 +101,7 @@ /** * Calculates the position in the modified text. + * * @param historicOffset position in the unmodified text. * @return position in the modified text. */ @@ -117,7 +119,8 @@ /** * Makes this tracker final. Future changes are tracked by the tracker - * supplied and will be taken into acoount when converting positions. + * supplied and will be taken into account when converting positions. + * * @param inFavourOf tracker that tracks changes from now on. */ public synchronized void retire(PositionTracker inFavourOf) { @@ -173,7 +176,7 @@ int historic= historicOffset(actual, true); if (len > 0) { - len= historicOffset(actual+len-1, false) - historic + 1; + len= historicOffset(actual + len - 1, false) - historic + 1; } assert len >= 0; return new Region(historic, len); @@ -186,7 +189,7 @@ int actual= currentOffset(historic, true); if (len > 0) { - len= currentOffset(historic+len-1, false) - actual + 1; + len= currentOffset(historic + len - 1, false) - actual + 1; } assert len >= 0; return new Region(actual, len); @@ -194,15 +197,16 @@ /** * Nodes implementing a red black binary tree. + * * @author markus.schorn@windriver.com */ private static class Node { private static final boolean RED = true; private static final boolean BLACK = false; - private int fDeltaPos2; // sum of this and pos2 of parent yields pos2. + private int fDeltaPos2; // Sum of this and pos2 of parent yields pos2. private int fPos1; - private int fChange; // lenght of text change (+ add, - remove) + private int fChange; // Length of text change (+ add, - remove) private boolean fColor; private Node fLeft; @@ -230,61 +234,61 @@ return StrictMath.max(fLeft.depth(), fRight.depth()) + 1; } - // forward calculation + // Forward calculation. int calculateCurrentOffset(int value1, int parentPos2, boolean nextOnDelete) { int fPos2 = parentPos2 + fDeltaPos2; int rel1 = value1 - fPos1; - // is value ahead of this change? + // Is value ahead of this change? if (rel1 < 0) { if (fLeft != null) { return fLeft.calculateCurrentOffset(value1, fPos2, nextOnDelete); } - // value is directly ahead of this change. + // Value is directly ahead of this change. return rel1 + fPos2; } - // is value deleted by this? + // Is value deleted by this? if (rel1 < -fChange) { - return nextOnDelete ? fPos2 : fPos2-1; + return nextOnDelete ? fPos2 : fPos2 - 1; } - // value is after this change. + // Value is after this change. if (fRight != null) { return fRight.calculateCurrentOffset(value1, fPos2, nextOnDelete); } - // value is directly after this change. + // Value is directly after this change. return rel1 + fPos2 + fChange; } - // backward calculation + // Backward calculation. int calculateOriginalOffset(int value2, int parentPos2, boolean nextOnDelete) { int fPos2 = parentPos2 + fDeltaPos2; int rel2 = value2 - fPos2; - // is value ahead of this change? + // Is value ahead of this change? if (rel2 < 0) { if (fLeft != null) { return fLeft.calculateOriginalOffset(value2, fPos2, nextOnDelete); } - // value is directly ahead of this change. + // Value is directly ahead of this change. return rel2 + fPos1; } - // is value added by this? + // Is value added by this? if (rel2 < fChange) { - return nextOnDelete ? fPos1 : fPos1-1; + return nextOnDelete ? fPos1 : fPos1 - 1; } - // offset is behind this change. + // Offset is behind this change. if (fRight != null) { return fRight.calculateOriginalOffset(value2, fPos2, nextOnDelete); } - // offset is directly behind this change. + // Offset is directly behind this change. return rel2 + fPos1 - fChange; } @@ -292,48 +296,47 @@ int rel2 = value2 - fPos2; if (fParent != null) { - fParent.balance(); // this may change both the parent and fDeltaPos2; + fParent.balance(); // This may change both the parent and fDeltaPos2; } - // added ahead of this change? + // Added ahead of this change? if (rel2 < 0) { - fDeltaPos2 += add; // advance + fDeltaPos2 += add; // Advance if (fLeft != null) { int childPos2 = fPos2 + fLeft.fDeltaPos2; - fLeft.fDeltaPos2 -= add; // unadvance - fLeft.addChars(value2, add, childPos2); // use modified parent pos + fLeft.fDeltaPos2 -= add; // Unadvance + fLeft.addChars(value2, add, childPos2); // Use modified parent pos return; } - addLeft(rel2 + fPos1, rel2 - add, add); // modify delta pos + addLeft(rel2 + fPos1, rel2 - add, add); // Modify delta pos return; } - // added inside range of another change? - int range2 = (fChange > 0) ? fChange : 0; + // Added inside range of another change? + int range2 = fChange > 0 ? fChange : 0; if (rel2 <= range2 && !isHolder()) { fChange += add; - // insert in a deletion at the end - if (fChange<=0) { - fPos1+= add; - fDeltaPos2+= add; + // Insert in a deletion at the end + if (fChange <= 0) { + fPos1 += add; + fDeltaPos2 += add; if (fLeft != null) { fLeft.fDeltaPos2 -= add; } - } - else if (fRight != null) { + } else if (fRight != null) { fRight.fDeltaPos2 += add; // advance right branch } return; } - // added behind this change. + // Added behind this change. if (fRight != null) { fRight.addChars(value2, add, fPos2 + fRight.fDeltaPos2); return; } - // added directly behind this change + // Added directly behind this change. addRight(rel2 + fPos1 - fChange, rel2, add); } @@ -341,16 +344,16 @@ int relFirstChar2 = firstChar2 - fPos2; int relAfterLastChar2 = relFirstChar2 + remove; - // no insertion - no balancing + // No insertion - no balancing if (mustRemove && fParent != null) { fParent.balance(); } - // ahead and no merge possible + // Ahead and no merge possible. if (relAfterLastChar2 < 0) { - fDeltaPos2 -= remove; // advance + fDeltaPos2 -= remove; // Advance if (fLeft != null) { - fLeft.fDeltaPos2 += remove; // unadvance + fLeft.fDeltaPos2 += remove; // Unadvance return fLeft.removeChars(firstChar2, remove, fPos2 - remove + fLeft.fDeltaPos2, mustRemove); } @@ -361,7 +364,7 @@ return false; } - // behind and no merge possible + // Behind and no merge possible. int range2 = (fChange > 0) ? fChange : 0; if (relFirstChar2 > range2 || isHolder()) { if (fRight != null) { @@ -386,7 +389,7 @@ } int delInside = remove - delAbove - delBelow; - // delegate above to left children + // Delegate above to left children. if (delAbove > 0 && fLeft != null) { if (fLeft.removeChars(firstChar2, delAbove, fPos2 + fLeft.fDeltaPos2, false)) { fDeltaPos2 -= delAbove; @@ -395,14 +398,14 @@ delAbove = 0; } } - // delegate below to right children + // Delegate below to right children. if (delBelow > 0 && fRight != null) { if (fRight.removeChars(fPos2 + range2, delBelow, fPos2 + fRight.fDeltaPos2, false)) { delBelow = 0; } } - // do the adjustments in this node + // Do the adjustments in this node. fChange -= delAbove + delInside + delBelow; fDeltaPos2 -= delAbove; fPos1 -= delAbove; @@ -485,7 +488,7 @@ int aboveLeft = -root.fDeltaPos2 - left.fDeltaPos2; int leftRoot = left.fDeltaPos2; - // put under old parent + // Put under old parent. if (fParent.fLeft == this) { fParent.putLeft(left); } else { @@ -493,7 +496,7 @@ } left.fDeltaPos2 += rootAbove; - // change the right node + // Change the right node. left.putRight(root); root.fDeltaPos2 += aboveLeft; @@ -515,7 +518,7 @@ int parentRight = -root.fDeltaPos2 - right.fDeltaPos2; int rightRoot = right.fDeltaPos2; - // put under old parent + // Put under old parent. if (fParent.fRight == this) { fParent.putRight(right); } else { @@ -523,11 +526,11 @@ } right.fDeltaPos2 += rootAbove; - // change the left node + // Change the left node. right.putLeft(root); root.fDeltaPos2 += parentRight; - // change right of left node. + // Change right of left node. root.putRight(rightLeft); if (rightLeft != null) { rightLeft.fDeltaPos2 += rightRoot; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerManager.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerManager.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerManager.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/PositionTrackerManager.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core; @@ -99,14 +99,19 @@ @Override public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {} + @Override public void bufferContentReplaced(IFileBuffer buffer) {} + @Override public void underlyingFileMoved(IFileBuffer buffer, IPath path) {} + @Override public void underlyingFileDeleted(IFileBuffer buffer) {} + @Override public void stateChangeFailed(IFileBuffer buffer) {} + @Override public void stateChanging(IFileBuffer buffer) {} @@ -194,9 +199,6 @@ } } - /** - * {@inheritDoc} - */ @Override public synchronized IPositionConverter findPositionConverter(IFile file, long timestamp) { PositionTrackerChain chain= fPositionTrackerMap.get(file.getFullPath()); @@ -206,9 +208,6 @@ return null; } - /** - * {@inheritDoc} - */ @Override public synchronized IPositionConverter findPositionConverter(IPath externalLocation, long timestamp) { PositionTrackerChain chain= fPositionTrackerMap.get(externalLocation); @@ -218,9 +217,6 @@ return null; } - /** - * {@inheritDoc} - */ @Override public synchronized IPositionConverter findPositionConverter(ITranslationUnit tu, long timestamp) { IFile file= (IFile) tu.getResource(); @@ -240,9 +236,6 @@ return null; } - /** - * {@inheritDoc} - */ @Override public synchronized IPositionConverter findPositionConverter(URI locationURI, long timestamp) { PositionTrackerChain chain= fPositionTrackerMap.get(locationURI); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProblemMarkerFilterDesc.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProblemMarkerFilterDesc.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProblemMarkerFilterDesc.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProblemMarkerFilterDesc.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,10 +1,10 @@ -/* +/******************************************************************************* * Copyright (c) 2014 BlackBerry Limited 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 - */ + *******************************************************************************/ package org.eclipse.cdt.internal.core; import java.util.Arrays; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProblemMarkerFilterManager.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProblemMarkerFilterManager.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProblemMarkerFilterManager.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/ProblemMarkerFilterManager.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,10 +1,10 @@ -/* +/******************************************************************************* * Copyright (c) 2014 BlackBerry Limited 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 - */ + *******************************************************************************/ package org.eclipse.cdt.internal.core; import java.util.ArrayList; @@ -17,7 +17,6 @@ import org.eclipse.cdt.core.IProblemMarkerFilter; import org.eclipse.cdt.core.ProblemMarkerInfo; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java 2015-02-11 19:19:10.000000000 +0000 @@ -17,6 +17,13 @@ import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTFileLocation; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTNodeSelector; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; +import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage; import org.eclipse.cdt.core.formatter.CodeFormatter; @@ -33,6 +40,8 @@ import org.eclipse.cdt.core.parser.IncludeFileContentProvider; import org.eclipse.cdt.core.parser.ParserUtil; import org.eclipse.cdt.core.parser.ScannerInfo; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; +import org.eclipse.cdt.internal.core.util.TextUtil; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; @@ -185,6 +194,11 @@ IASTTranslationUnit ast) { for (int i = 0; i < regions.length; i++) { IRegion region = regions[i]; + if (shouldFormatWholeStatements()) { + // An empty region is replaced by the region containing the line corresponding to + // the offset and all statements overlapping with that line. + region = getLineOrStatementRegion(source, region, ast); + } CodeFormatterVisitor codeFormatter = new CodeFormatterVisitor(preferences, region.getOffset(), region.getLength()); edits[i] = codeFormatter.format(source, ast); @@ -195,6 +209,79 @@ } } + private boolean shouldFormatWholeStatements() { + Object obj = options.get(DefaultCodeFormatterConstants.FORMATTER_STATEMENT_SCOPE); + return obj instanceof Boolean && ((Boolean) obj).booleanValue(); + } + + /** + * Returns the smallest region containing the lines overlapping with the given region and all + * statements overlapping with those lines. + */ + private IRegion getLineOrStatementRegion(String source, IRegion region, IASTTranslationUnit ast) { + int start = TextUtil.getLineStart(source, region.getOffset()); + int end = TextUtil.skipToNextLine(source, region.getOffset() + region.getLength()); + IASTNode node = findOverlappingPreprocessorStatement(start, end, ast); + if (node != null) { + IASTFileLocation location = node.getFileLocation(); + int nodeOffset = location.getNodeOffset(); + if (nodeOffset < start) + start = nodeOffset; + int nodeEnd = nodeOffset + location.getNodeLength(); + if (nodeEnd > end) + end = nodeEnd; + return new Region(start, end - start); + } + IASTNodeSelector nodeSelector = ast.getNodeSelector(null); + for (int pos = start; pos < end;) { + node = nodeSelector.findFirstContainedNode(pos, end - pos); + if (node != null) { + IASTNode containedNode = node; + node = CPPVisitor.findAncestorWithType(containedNode, IASTStatement.class); + if (node == null) + node = CPPVisitor.findAncestorWithType(containedNode, IASTDeclaration.class); + if (node == null) + node = CPPVisitor.findAncestorWithType(containedNode, IASTPreprocessorMacroExpansion.class); + } + if (node == null) + break; + IASTFileLocation location = node.getFileLocation(); + int nodeOffset = location.getNodeOffset(); + if (nodeOffset < start) + start = nodeOffset; + int nodeEnd = nodeOffset + location.getNodeLength(); + if (nodeEnd > end) + end = nodeEnd; + pos = nodeEnd; + } + + return new Region(start, end - start); + } + + private IASTNode findOverlappingPreprocessorStatement(int start, int end, IASTTranslationUnit ast) { + IASTPreprocessorStatement[] statements = ast.getAllPreprocessorStatements(); + int low = 0; + int high = statements.length; + while (low < high) { + int mid = (low + high) >>> 1; + IASTPreprocessorStatement statement = statements[mid]; + IASTFileLocation location = statement.getFileLocation(); + if (location == null) { + low = mid + 1; + } else { + int statementOffset = location.getNodeOffset(); + if (statementOffset >= end) { + high = mid; + } else if (statementOffset + location.getNodeLength() <= start) { + low = mid + 1; + } else { + return statement; + } + } + } + return null; + } + private ITranslationUnit getTranslationUnit(String source) { ITranslationUnit tu= (ITranslationUnit) options.get(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT); if (tu == null) { diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/ChangeFormatter.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/ChangeFormatter.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/ChangeFormatter.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/ChangeFormatter.java 2015-02-11 19:19:10.000000000 +0000 @@ -72,13 +72,15 @@ int newEnd = lineInfo.getOffset(); newEnd = (originalEnd == 0 || code.charAt(originalEnd - 1) == '\n') && end == newEnd ? end : endOffset(lineInfo); - if (newOffset <= prevEnd) { + if (newOffset <= prevEnd && numRegions > 0) { numRegions--; newOffset = regions[numRegions].getOffset(); } prevEnd = newEnd; - regions[numRegions] = new Region(newOffset, newEnd - newOffset); - numRegions++; + if (newEnd != newOffset) { // Don't produce empty regions. + regions[numRegions] = new Region(newOffset, newEnd - newOffset); + numRegions++; + } } if (numRegions == 0) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2014 Wind River Systems, 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 @@ -289,6 +289,12 @@ public void run() { boolean needSpace = skipConstVolatileRestrict(); int token = peekNextToken(); + // Ref-qualifier. + if (token == Token.tAMPER || token == Token.tAND) { + scribe.printNextToken(token, true); + token = peekNextToken(); + needSpace = true; + } if (token == Token.t_throw || token == Token.tIDENTIFIER) { if (node instanceof ICPPASTFunctionDeclarator) { final IASTTypeId[] exceptionSpecification= @@ -1417,48 +1423,6 @@ formatList(parameters, options, true, node.takesVarArgs(), new FunctionDeclaratorTailFormatter(node, tailFormatter)); -// IASTFileLocation fileLocation= node.getFileLocation(); -// if (fileLocation != null && -// scribe.scanner.getCurrentPosition() < fileLocation.getNodeOffset() + fileLocation.getNodeLength()) { -// skipConstVolatileRestrict(); -// -// int token = peekNextToken(); -// if (token == Token.t_throw || token == Token.tIDENTIFIER) { -// final IASTTypeId[] exceptionSpecification= node.getExceptionSpecification(); -// if (exceptionSpecification != null && token == Token.t_throw) -// formatExceptionSpecification(exceptionSpecification); -// if (peekNextToken() == Token.tIDENTIFIER) { -// Alignment alignment = scribe.createAlignment( -// Alignment.TRAILING_TEXT, -// Alignment.M_COMPACT_SPLIT, -// 1, -// scribe.scanner.getCurrentPosition()); -// -// scribe.enterAlignment(alignment); -// boolean ok = false; -// do { -// try { -// scribe.alignFragment(alignment, 0); -// // Skip the rest of the declarator. -// scribe.printTrailingComment(); -// scribe.space(); -// if (tailFormatter != null) -// tailFormatter.run(); -// skipNode(node); -// ok = true; -// } catch (AlignmentException e) { -// scribe.redoAlignment(e); -// } -// } while (!ok); -// scribe.exitAlignment(alignment, true); -// } -// } else { -// // Skip the rest (=0) -// scribe.printTrailingComment(); -// scribe.space(); -// skipNode(node); -// } -// } return PROCESS_SKIP; } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64Factory.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64Factory.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64Factory.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64Factory.java 2015-02-11 19:19:10.000000000 +0000 @@ -80,4 +80,11 @@ public IAddress createAddress(BigInteger addr, boolean truncate) { return new Addr64(addr, truncate); } + + /** + * @since 5.9 + */ + public IAddress createAddress(long addr) { + return new Addr64(addr); + } } \ No newline at end of file diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java 2015-02-11 19:19:10.000000000 +0000 @@ -14,6 +14,7 @@ import java.io.Serializable; import java.math.BigInteger; +import java.nio.ByteBuffer; import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.internal.core.Messages; @@ -51,6 +52,19 @@ this(addr, true); } + /** + * Create an address represented by long bits. + * Signed bit will be used as unsigned extension, if you don't want it mask it before passing here. + * + * @since 5.9 + */ + public Addr64(long addr) { + if (addr < 0) + address = new BigInteger(1, ByteBuffer.allocate(8).putLong(addr).array()); + else + address = BigInteger.valueOf(addr); + } + public Addr64(String addr, boolean truncate) { addr = addr.toLowerCase(); if (addr.startsWith("0x")) { //$NON-NLS-1$ diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java 2015-02-11 19:19:10.000000000 +0000 @@ -285,7 +285,11 @@ } protected ResolvedMacro resolveMacro(String macroName) throws CdtVariableException{ - return resolveMacro(SupplierBasedCdtVariableManager.getVariable(macroName,fContextInfo,true)); + ICdtVariable variable = SupplierBasedCdtVariableManager.getVariable(macroName,fContextInfo,true); + if (variable == null) + return null; + + return resolveMacro(variable); } protected ResolvedMacro resolveParentMacro(MacroDescriptor macroDes) throws CdtVariableException{ diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java 2015-02-11 19:19:10.000000000 +0000 @@ -534,7 +534,7 @@ } Map parseDebugAbbreviation(CompilationUnitHeader header) throws IOException { - Integer key = new Integer(header.abbreviationOffset); + Integer key = Integer.valueOf(header.abbreviationOffset); Map abbrevs = abbreviationMaps.get(key); if (abbrevs == null) { abbrevs = new HashMap(); @@ -644,27 +644,27 @@ break; case DwarfConstants.DW_FORM_data1 : - obj = new Byte(in.get()); + obj = Byte.valueOf(in.get()); break; case DwarfConstants.DW_FORM_data2 : - obj = new Short(read_2_bytes(in)); + obj = Short.valueOf(read_2_bytes(in)); break; case DwarfConstants.DW_FORM_data4 : - obj = new Integer(read_4_bytes(in)); + obj = Integer.valueOf(read_4_bytes(in)); break; case DwarfConstants.DW_FORM_data8 : - obj = new Long(read_8_bytes(in)); + obj = Long.valueOf(read_8_bytes(in)); break; case DwarfConstants.DW_FORM_sdata : - obj = new Long(read_signed_leb128(in)); + obj = Long.valueOf(read_signed_leb128(in)); break; case DwarfConstants.DW_FORM_udata : - obj = new Long(read_unsigned_leb128(in)); + obj = Long.valueOf(read_unsigned_leb128(in)); break; case DwarfConstants.DW_FORM_string : @@ -682,7 +682,7 @@ break; case DwarfConstants.DW_FORM_flag : - obj = new Byte(in.get()); + obj = Byte.valueOf(in.get()); break; case DwarfConstants.DW_FORM_strp : @@ -742,23 +742,23 @@ break; case DwarfConstants.DW_FORM_ref1 : - obj = new Byte(in.get()); + obj = Byte.valueOf(in.get()); break; case DwarfConstants.DW_FORM_ref2 : - obj = new Short(read_2_bytes(in)); + obj = Short.valueOf(read_2_bytes(in)); break; case DwarfConstants.DW_FORM_ref4 : - obj = new Integer(read_4_bytes(in)); + obj = Integer.valueOf(read_4_bytes(in)); break; case DwarfConstants.DW_FORM_ref8 : - obj = new Long(read_8_bytes(in)); + obj = Long.valueOf(read_8_bytes(in)); break; case DwarfConstants.DW_FORM_ref_udata : - obj = new Long(read_unsigned_leb128(in)); + obj = Long.valueOf(read_unsigned_leb128(in)); break; case DwarfConstants.DW_FORM_indirect : diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.aix/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.aix/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.aix/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.aix/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml @@ -15,6 +15,52 @@ org.eclipse.cdt.core.linux eclipse-plugin + + + ppc64le + + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + p2 + consider + + + linux + gtk + ppc64le + + + linux + gtk + x86 + + + linux + gtk + x86_64 + + + linux + gtk + ppc + + + linux + gtk + ppc64 + + + + + + + + + diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ia64/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ia64/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ia64/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ia64/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/about.html eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/about.html --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/about.html 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/about.html 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,24 @@ + + +About + + +

About This Content

+ +

Jan 21, 2011

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + \ No newline at end of file diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/build.properties eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/build.properties --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/build.properties 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/build.properties 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,14 @@ +############################################################################### +# Copyright (c) 2014 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +bin.includes = os/,\ + about.html,\ + META-INF/ +src.includes = about.html diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/META-INF/MANIFEST.MF eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/META-INF/MANIFEST.MF --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/META-INF/MANIFEST.MF 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/META-INF/MANIFEST.MF 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-SymbolicName: org.eclipse.cdt.core.linux.ppc64le;singleton:=true +Bundle-ManifestVersion: 2 +Bundle-Localization: plugin +Bundle-Name: %fragmentName.linux.ppc64le +Bundle-Version: 1.0.0.qualifier +Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[5.7.0,6.0.0)" +Bundle-Vendor: %providerName +Eclipse-PlatformFilter: (&(osgi.os=linux)(osgi.arch=ppc64le)) diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,53 @@ + + + 4.0.0 + + + org.eclipse.cdt + cdt-parent + 8.6.0-SNAPSHOT + ../../pom.xml + + + 1.0.0-SNAPSHOT + org.eclipse.cdt.core.linux.ppc64le + eclipse-plugin + + + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + p2 + consider + + + linux + gtk + ppc64le + + + + + + org.eclipse.tycho + tycho-source-plugin + ${tycho-version} + + + plugin-source + none + + + attach-source + none + + + + + + diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/.project eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/.project --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.ppc64le/.project 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.ppc64le/.project 2015-02-11 19:19:10.000000000 +0000 @@ -0,0 +1,22 @@ + + + org.eclipse.cdt.core.linux.ppc64le + + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + + diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.x86/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.x86/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.x86/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.x86/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.x86_64/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.x86_64/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.linux.x86_64/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.linux.x86_64/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.macosx/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.macosx/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.macosx/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.macosx/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.native/plugin.properties eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.native/plugin.properties --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.native/plugin.properties 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.native/plugin.properties 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2014 IBM Corporation and others. +# Copyright (c) 2003, 2015 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 @@ -18,6 +18,7 @@ fragmentName.linux.ia64 = C/C++ Development Tools Core Native Utilities for Linux (ia64) fragmentName.linux.ppc = C/C++ Development Tools Core Native Utilities for Linux (ppc) fragmentName.linux.ppc64 = C/C++ Development Tools Core Native Utilities for Linux (ppc64) +fragmentName.linux.ppc64le = C/C++ Development Tools Core Native Utilities for Linux (ppc64le) fragmentName.linux.x86 = C/C++ Development Tools Core Native Utilities for Linux (x86) fragmentName.linux.x86_64 = C/C++ Development Tools Core Native Utilities for Linux (x86_64) fragmentName.qnx = C/C++ Development Tools Core Native Utilities for QNX diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.native/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.native/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.native/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.native/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.solaris/pom.xml eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.solaris/pom.xml --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.solaris/pom.xml 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.solaris/pom.xml 2015-02-11 19:19:10.000000000 +0000 @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.5.0-SNAPSHOT + 8.6.0-SNAPSHOT ../../pom.xml diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF 2015-02-11 19:19:10.000000000 +0000 @@ -20,10 +20,6 @@ org.eclipse.cdt.core.parser.tests.rewrite, org.eclipse.cdt.core.parser.tests.rewrite.astwriter, org.eclipse.cdt.core.parser.tests.rewrite.changegenerator, - org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.append, - org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore, - org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.remove, - org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace, org.eclipse.cdt.core.parser.tests.rewrite.comenthandler, org.eclipse.cdt.core.parser.tests.scanner, org.eclipse.cdt.core.resources.tests, diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/PositionTrackerTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/PositionTrackerTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/PositionTrackerTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/PositionTrackerTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.core.internal.tests; import java.util.Random; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -72,7 +72,7 @@ CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { - ICProject cProject = CProjectHelper.createNewStileCProject("testRefreshScope", IPDOMManager.ID_NO_INDEXER, false); + ICProject cProject = CProjectHelper.createNewStyleCProject("testRefreshScope", IPDOMManager.ID_NO_INDEXER, false); fProject = cProject.getProject(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -361,8 +361,8 @@ // bug 179474 public void testSourceExclusionFilters_179474() throws Exception { ICProject testProject; - testProject=CProjectHelper.createCProject("bug179474", "none", IPDOMManager.ID_NO_INDEXER); - if (testProject==null) + testProject= CProjectHelper.createCProject("bug179474", "none", IPDOMManager.ID_NO_INDEXER); + if (testProject == null) fail("Unable to create project"); IFolder subFolder = testProject.getProject().getFolder("sub"); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -63,7 +63,7 @@ } public void testPathEntriesForNewStyle() throws Exception { - p1 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "a", TestUserAndDiscoveredEntriesCfgDataProvider.PROVIDER_ID, IPDOMManager.ID_NO_INDEXER); + p1 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "a", TestUserAndDiscoveredEntriesCfgDataProvider.PROVIDER_ID, IPDOMManager.ID_NO_INDEXER); IProject project = p1.getProject(); IPathEntry[] entries = CoreModel.getRawPathEntries(p1); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -39,7 +39,7 @@ int wspRel = prefs.getConfigurationRelations(); CoreModel model = CoreModel.getDefault(); - p1 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER); + p1 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER); IProject project = p1.getProject(); ICProjectDescription des = model.getProjectDescription(project, false); assertEquals(wspRel, des.getConfigurationRelations()); diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -65,7 +65,7 @@ } public void testModulesCopiedOnCreateNewConfig() throws Exception { - ICProject p = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "c", IPDOMManager.ID_NO_INDEXER); + ICProject p = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "c", IPDOMManager.ID_NO_INDEXER); p3 = p.getProject(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -186,7 +186,7 @@ } public void testSetDescriptionWithRootIncompatibleRuleAquired() throws Exception { - ICProject p = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "4", IPDOMManager.ID_NO_INDEXER); + ICProject p = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "4", IPDOMManager.ID_NO_INDEXER); p4 = p.getProject(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -225,7 +225,7 @@ // Emulate entering Eclipse first time { // Create model project and accompanied descriptions - ICProject cproject = CProjectHelper.createNewStileCProject(projectName, IPDOMManager.ID_NO_INDEXER); + ICProject cproject = CProjectHelper.createNewStyleCProject(projectName, IPDOMManager.ID_NO_INDEXER); IProject project = cproject.getProject(); // Initial project description after opening a project diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -62,7 +62,7 @@ @Override protected void setUp() throws Exception { - cProj = CProjectHelper.createNewStileCProject("CProjDescStorage", IPDOMManager.ID_FAST_INDEXER); + cProj = CProjectHelper.createNewStyleCProject("CProjDescStorage", IPDOMManager.ID_FAST_INDEXER); resListener = new OurResourceChangeListener(); ResourcesPlugin.getWorkspace().addResourceChangeListener(resListener); } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -41,12 +41,12 @@ @Override protected void setUp() throws Exception { - p1 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER); - p2 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "b", IPDOMManager.ID_NO_INDEXER); - p3 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "c", IPDOMManager.ID_NO_INDEXER); - p4 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "d", IPDOMManager.ID_NO_INDEXER); - p5 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "e", IPDOMManager.ID_NO_INDEXER); - p6 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "f", IPDOMManager.ID_NO_INDEXER); + p1 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER); + p2 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "b", IPDOMManager.ID_NO_INDEXER); + p3 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "c", IPDOMManager.ID_NO_INDEXER); + p4 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "d", IPDOMManager.ID_NO_INDEXER); + p5 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "e", IPDOMManager.ID_NO_INDEXER); + p6 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "f", IPDOMManager.ID_NO_INDEXER); } /** diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -115,7 +115,7 @@ initListener(projName); - ICProject cp1 = CProjectHelper.createNewStileCProject(projName, IPDOMManager.ID_NO_INDEXER, true); + ICProject cp1 = CProjectHelper.createNewStyleCProject(projName, IPDOMManager.ID_NO_INDEXER, true); IProject project = cp1.getProject(); p1 = project; assertTrue(listener.isNotified()); @@ -246,7 +246,7 @@ initListener(projName); - ICProject cp3 = CProjectHelper.createNewStileCProject(projName, IPDOMManager.ID_NO_INDEXER, true); + ICProject cp3 = CProjectHelper.createNewStyleCProject(projName, IPDOMManager.ID_NO_INDEXER, true); IProject project = cp3.getProject(); p3 = project; @@ -308,7 +308,7 @@ initListener(projName); - ICProject cp4 = CProjectHelper.createNewStileCProject(projName, IPDOMManager.ID_NO_INDEXER, false); + ICProject cp4 = CProjectHelper.createNewStyleCProject(projName, IPDOMManager.ID_NO_INDEXER, false); IProject project = cp4.getProject(); p4 = project; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java 2015-02-11 19:19:10.000000000 +0000 @@ -2242,6 +2242,31 @@ parse(getAboveComment(), ParserLanguage.CPP, true, 0); } + //class A { + // void a() & {} + // void b() && {} + // + // void c() const& {} + // void d() const&& {} + // + // void e() volatile & {} + // void f() volatile && {} + // + // void g() volatile const& {} + // void h() volatile const&& {} + //}; + public void test8s4() throws Exception { + parse(getAboveComment(), ParserLanguage.CPP, true, 0); + } + + // void print(int a, int) + // { + // //printf("a = %d",a); + // } + public void test8_4s5() throws Exception { + parse(getAboveComment(), ParserLanguage.CPP, true, 0); + } + // int a; // struct X { // static int a; @@ -5717,7 +5742,7 @@ // template int f(T[5]); // int I = f(0); - // int j = f(0); // invalid array // also no error with gcc + // int j = f(0); // invalid array public void _test14_8_2s8b() throws Exception { final String content= getAboveComment(); BindingAssertionHelper bh= new BindingAssertionHelper(content, true); @@ -6593,14 +6618,6 @@ parse(getAboveComment(), ParserLanguage.CPP, false, 0); } - // void print(int a, int) - // { - // //printf("a = %d",a); - // } - public void test8_4s5() throws Exception { - parse(getAboveComment(), ParserLanguage.CPP, true, 0); - } - // int a; // const int b = a; // int c = b; diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -139,8 +139,11 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator; 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.CPPClassType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; @@ -328,16 +331,16 @@ parseAndCheckBindings(); } - // int *p1; int *p2; - // union { - // struct {int a; int b;} A; - // struct {int a; int b;}; - // } MyStruct; - // void test (void) { - // p1 = &MyStruct.A.a; - // p2 = &MyStruct.b; - // MyStruct.b = 1; - // } + // int *p1; int *p2; + // union { + // struct {int a; int b;} A; + // struct {int a; int b;}; + // } MyStruct; + // void test (void) { + // p1 = &MyStruct.A.a; + // p2 = &MyStruct.b; + // MyStruct.b = 1; + // } public void testBug78103() throws Exception { parseAndCheckBindings(getAboveComment()); } @@ -347,7 +350,7 @@ // B(int t); // }; // class A : public B { - // public: + // public: // A(int t); // }; // A::A(int t) : B(t - 1) {} @@ -401,12 +404,12 @@ assertTrue(es.getExpression() instanceof IASTFunctionCallExpression); } - // #define CURLOPTTYPE_OBJECTPOINT 10000 - // #define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number - // typedef enum { - // CINIT(FILE, OBJECTPOINT, 1), - // CINIT(URL, OBJECTPOINT, 2) - // } CURLoption ; + // #define CURLOPTTYPE_OBJECTPOINT 10000 + // #define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number + // typedef enum { + // CINIT(FILE, OBJECTPOINT, 1), + // CINIT(URL, OBJECTPOINT, 2) + // } CURLoption; public void testBug102825() throws Exception { parseAndCheckBindings(getAboveComment()); } @@ -2884,11 +2887,11 @@ assertNotNull(whileStatement.getConditionDeclaration()); } - // void foo() { - // const int x = 12; - // { enum { x = x }; } - // } - // enum { RED }; + // void foo() { + // const int x = 12; + // { enum { x = x }; } + // } + // enum { RED }; public void testBug86353() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4629,12 +4632,12 @@ assertInstances(col, B, 4); } - // class X { - // public: - // void f(int); - // int a; - // }; - // int X:: * pmi = &X::a; + // class X { + // public: + // void f(int); + // int a; + // }; + // int X:: * pmi = &X::a; public void testBasicPointerToMember() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); assertEquals(tu.getDeclarations().length, 2); @@ -4644,12 +4647,11 @@ assertEquals("X::", po.getName().toString()); } - // struct B {}; - // struct D : B {}; - // void foo(D* dp) - // { - // B* bp = dynamic_cast(dp); - // } + // struct B {}; + // struct D : B {}; + // void foo(D* dp) { + // B* bp = dynamic_cast(dp); + // } public void testBug84466() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); ICPPASTCastExpression dynamic_cast = @@ -4663,8 +4665,7 @@ } public void testBug88338_CPP() throws Exception { - IASTTranslationUnit tu = parse( - "struct A; struct A* a;", CPP); + IASTTranslationUnit tu = parse("struct A; struct A* a;", CPP); NameCollector col = new NameCollector(); tu.accept(col); @@ -4692,11 +4693,11 @@ assertEquals(f.getNestedDeclarator().getName().toString(), "pfi"); } - // class X { public: int bar; }; - // void f(){ - // X a[10]; - // a[0].bar; - // } + // class X { public: int bar; }; + // void f(){ + // X a[10]; + // a[0].bar; + // } public void testBug95484() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4706,10 +4707,10 @@ assertSame(bar, col.getName(6).resolveBinding()); } - // int strcmp(const char *); - // void f(const char * const * argv){ - // strcmp(*argv); - // } + // int strcmp(const char *); + // void f(const char * const * argv){ + // strcmp(*argv); + // } public void testBug95419() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4719,14 +4720,14 @@ assertSame(strcmp, col.getName(4).resolveBinding()); } - // class Other; - // class Base { - // public: Base(Other *); - // }; - // class Sub : public Base { - // public: Sub(Other *); - // }; - // Sub::Sub(Other * b) : Base(b) {} + // class Other; + // class Base { + // public: Base(Other *); + // }; + // class Sub : public Base { + // public: Sub(Other *); + // }; + // Sub::Sub(Other * b) : Base(b) {} public void testBug95673() throws Exception { BindingAssertionHelper ba= getAssertionHelper(); @@ -4735,12 +4736,12 @@ assertSame(ctor, ctor2); } - // void mem(void *, const void *); - // void f() { - // char *x; int offset; - // mem(x, "FUNC"); - // mem(x + offset, "FUNC2"); - // } + // void mem(void *, const void *); + // void f() { + // char *x; int offset; + // mem(x, "FUNC"); + // mem(x + offset, "FUNC2"); + // } public void testBug95768() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4908,14 +4909,14 @@ assertSame(i, col.getName(7).resolveBinding()); } - // int f() { - // return 5; - // } - // int main() { - // int a(5); - // int b(f()); - // return a+b; - // } + // int f() { + // return 5; + // } + // int main() { + // int a(5); + // int b(f()); + // return a+b; + // } public void testBug86849() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -6263,24 +6264,24 @@ // void test2(char []); // void test3(t); // void xx() { - // char* x= 0; - // test1(x); - // test2(x); // problem binding here - // test3(x); // problem binding here + // char* x= 0; + // test1(x); + // test2(x); + // test3(x); // } public void testAdjustmentOfParameterTypes_239975() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } // class A { - // public: - // void m(int c); + // public: + // void m(int c); // }; // // void test(char c) { - // void (A::* ptr2mem)(char); - // ptr2mem= reinterpret_cast(&A::m); - // ptr2mem= (void (A::*)(int))(0); + // void (A::* ptr2mem)(char); + // ptr2mem= reinterpret_cast(&A::m); + // ptr2mem= (void (A::*)(int))(0); // } public void testTypeIdForPtrToMember_242197() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); @@ -7235,25 +7236,152 @@ ba.assertNonProblem("f(!p)", 1); } + // template + // struct A { + // enum { + // e1 = 0, + // e2 = int(e1) + // }; + // }; + // + // template::e2> + // struct B; + // + // template + // struct B { + // void waldo(); + // }; + // + // void test(B& p) { + // p.waldo(); + // } + public void testDependentEnumeration_446711a() throws Exception { + parseAndCheckBindings(); + } + + // constexpr int f(int p) { return p; } + // constexpr long f(long p) { return p + 0x100000000L; } + // + // template + // struct A { + // enum { + // e1 = 0, + // e2 = f(e1) + // }; + // }; + // + // template::e2> + // struct B; + // + // template + // struct B { + // void waldo(); + // }; + // + // void test(B& p) { + // p.waldo(); + // } + public void testDependentEnumeration_446711b() throws Exception { + parseAndCheckBindings(); + } + + // constexpr int f(long p) { return p; } + // constexpr long f(int p) { return p + 0x100000000L; } + // + // template + // struct A { + // enum { + // e1 = 0L, + // e2 = f(e1) + // }; + // }; + // + // template::e2> + // struct B; + // + // template + // struct B { + // void waldo(); + // }; + // + // void test(B& p) { + // p.waldo(); + // } + public void testDependentEnumeration_446711c() throws Exception { + parseAndCheckBindings(); + } + + // constexpr int f(int p) { return p; } + // constexpr long f(long p) { return p + 0x100000000L; } + // + // template + // struct A { + // enum { + // e1 = v, + // e2 = f(e1) + // }; + // }; + // + // template::e2> + // struct B; + // + // template + // struct B { + // void waldo(); + // }; + // + // void test(B& p) { + // p.waldo(); + // } + public void testDependentEnumeration_446711d() throws Exception { + parseAndCheckBindings(); + } + + // constexpr int f(int p) { return p; } + // constexpr long f(long p) { return p + 0x100000000L; } + // + // template + // struct A { + // enum { + // e1 = v, + // e2 = f(e1) + // }; + // }; + // + // template::e2> + // struct B {}; + // + // template + // struct B { + // void waldo(); + // }; + // + // void test(B& p) { + // p.waldo(); + // } + public void testDependentEnumeration_446711e() throws Exception { + BindingAssertionHelper helper = getAssertionHelper(); + helper.assertProblemOnFirstIdentifier(".waldo()"); + } + // class S { - // S(int); + // S(int); // }; // void test() { - // S **temp = new S*[1]; // problem on S - // temp = new S*; // problem on S - // temp = new (S*); // problem on S - // temp = new ::S*[1]; // problem on S - // temp = new ::S*; // problem on S - // temp = new (::S*); // problem on S + // S **temp = new S*[1]; + // temp = new S*; + // temp = new (S*); + // temp = new ::S*[1]; + // temp = new ::S*; + // temp = new (::S*); // } public void testNewPointerOfClass_267168() throws Exception { - final String code = getAboveComment(); - parseAndCheckBindings(code, CPP); + parseAndCheckBindings(); } // void f(char *(names[2])= 0); // void f2(const char *(n[])) { - // if (n && 1){} + // if (n && 1){} // } public void testPointerToArrayWithDefaultVal_267184() throws Exception { final String code = getAboveComment(); @@ -7270,10 +7398,10 @@ parseAndCheckBindings(code, CPP); } - // class X { - // virtual void pv() = 0; - // void (*ptrToFunc) ()= 0; - // }; + // class X { + // virtual void pv() = 0; + // void (*ptrToFunc) ()= 0; + // }; public void testPureVirtualVsInitDeclarator_267184() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu= parseAndCheckBindings(code, CPP); @@ -7545,11 +7673,11 @@ } // class C { - // C& operator()() {return *this;} + // C& operator()() { return *this; } // }; // void test() { - // C c; - // c()()()()()()()()()()()()()(); + // C c; + // c()()()()()()()()()()()()()(); // } public void testNestedOverloadedFunctionCalls_283324() throws Exception { final String code = getAboveComment(); @@ -7593,30 +7721,59 @@ ICPPFunction f1 = ba.assertNonProblem("f(i1)", 1, ICPPFunction.class); IType t1 = f1.getType().getParameterTypes()[0]; assertTrue(t1 instanceof ICPPBasicType); - assertEquals(IBasicType.t_int, ((ICPPBasicType) t1).getType()); - assertEquals(0, ((ICPPBasicType) t1).getQualifierBits()); + assertEquals(IBasicType.Kind.eInt, ((ICPPBasicType) t1).getKind()); + assertEquals(0, ((ICPPBasicType) t1).getModifiers()); ICPPFunction f2 = ba.assertNonProblem("f(u1)", 1, ICPPFunction.class); IType t2 = f2.getType().getParameterTypes()[0]; assertTrue(t2 instanceof ICPPBasicType); - assertEquals(IBasicType.t_int, ((ICPPBasicType) t2).getType()); - assertEquals(IBasicType.IS_UNSIGNED, ((ICPPBasicType) t2).getQualifierBits()); + assertEquals(IBasicType.Kind.eInt, ((ICPPBasicType) t2).getKind()); + assertEquals(IBasicType.IS_UNSIGNED, ((ICPPBasicType) t2).getModifiers()); ICPPFunction f3 = ba.assertNonProblem("f(l1)", 1, ICPPFunction.class); IType t3 = f3.getType().getParameterTypes()[0]; assertTrue(t3 instanceof ICPPBasicType); - assertEquals(IBasicType.t_int, ((ICPPBasicType) t3).getType()); - assertEquals(IBasicType.IS_LONG, ((ICPPBasicType) t3).getQualifierBits()); + assertEquals(IBasicType.Kind.eInt, ((ICPPBasicType) t3).getKind()); + assertEquals(IBasicType.IS_LONG, ((ICPPBasicType) t3).getModifiers()); } - // typedef enum enum_name enum_name; + // void f(int t); + // void f(long t); + // + // enum e { + // i1 = 0L, + // i2 = (long) i1 + 1, + // i3 = long(i2 + 1) + // }; + // + // void test() { + // f(i3); + // } + public void testCastInEnumeratorValue_446380() throws Exception { + BindingAssertionHelper ba= getAssertionHelper(); + IEnumerator i2 = ba.assertNonProblem("i2", IEnumerator.class); + Long v2 = i2.getValue().numericalValue(); + assertNotNull(v2); + assertEquals(1, v2.intValue()); + IEnumerator i3 = ba.assertNonProblem("i3", IEnumerator.class); + Long v3 = i3.getValue().numericalValue(); + assertNotNull(v3); + assertEquals(2, v3.intValue()); + ICPPFunction f = ba.assertNonProblemOnFirstIdentifier("f(i3)",ICPPFunction.class); + IType t = f.getType().getParameterTypes()[0]; + // The declared types of the enum values don't affect the underlying type of the enum, + // only the values themselves do. + assertEquals("int", ASTTypeUtil.getType(t)); + } + + // typedef enum enum_name enum_name; public void testTypedefRecursion_285457() throws Exception { BindingAssertionHelper ba= getAssertionHelper(); ba.assertProblem("enum_name", 9); } - // struct MyStruct { - // enum MyEnum {}; - // MyStruct(MyEnum value) {} - // }; + // struct MyStruct { + // enum MyEnum {}; + // MyStruct(MyEnum value) {} + // }; public void testEnumRedefinitionInStruct_385144() throws Exception { parseAndCheckBindings(); } @@ -7688,6 +7845,15 @@ checkDeclDef(declNames, defNames, cls.getMembers()); } + // #define MACRO "macro" + // void f(const char* s); + // void test() { + // f("aaa"MACRO); + // } + public void testStringConcatenationWithMacro() throws Exception { + parseAndCheckBindings(); + } + // class X { // struct S* m1; // struct T; @@ -8329,6 +8495,16 @@ parseAndCheckBindings(); } + // int foo = 0; + // auto bar = [foo] { return foo; }; + public void testLambdaWithCapture_446225() throws Exception { + BindingAssertionHelper bh = getAssertionHelper(); + ICPPVariable foo1= bh.assertNonProblemOnFirstIdentifier("foo =", ICPPVariable.class); + ICPPVariable foo2= bh.assertNonProblemOnFirstIdentifier("[foo]", ICPPVariable.class); + assertTrue(foo1 == foo2); + assertEquals(2, bh.getTranslationUnit().getReferences(foo1).length); + } + // typedef int TInt; // void test() { // int a1= {}, a2{}; // Initializer for declarator @@ -8566,6 +8742,67 @@ } // namespace std { + // template class initializer_list; + // } + // void waldo(int); + // void waldo(std::initializer_list); + // void foo() { + // waldo({}); + // waldo({1}); + // waldo({short(1)}); + // waldo({1, 2}); + // } + public void testListInitialization_439477a() throws Exception { + parseAndCheckBindings(); + } + + // void waldo(int const (&)[2]); + // void waldo(int const (&)[3]); + // void foo1() { + // waldo({1, 2}); // should resolve to waldo(int const (&)[2]) + // waldo({1, 2, 3}); // should resolve to waldo(int const (&)[3]) + // waldo({1, 2, 3, 4}); // should not resolve + // } + public void testListInitialization_439477b() throws Exception { + BindingAssertionHelper helper = getAssertionHelper(); + + ICPPFunction def1 = helper.assertNonProblem("waldo(int const (&)[2])", "waldo"); + ICPPFunction def2 = helper.assertNonProblem("waldo(int const (&)[3])", "waldo"); + + ICPPFunction call1 = helper.assertNonProblem("waldo({1, 2})", "waldo"); + ICPPFunction call2 = helper.assertNonProblem("waldo({1, 2, 3})", "waldo"); + + assertEquals(call1, def1); + assertEquals(call2, def2); + + helper.assertProblem("waldo({1, 2, 3, 4})", "waldo", IProblemBinding.SEMANTIC_NAME_NOT_FOUND); + } + + // namespace std { + // template + // class initializer_list { + // const E* _array; + // long unsigned int _len; + // + // initializer_list(const E* array, int len) {} + // }; + // } + // + // template + // struct A { + // A(std::initializer_list list) {} + // }; + // + // struct B { + // int b; + // }; + // + // A waldo({{0}, {0}}); + public void testListInitialization_458679() throws Exception { + parseAndCheckImplicitNameBindings(); + } + + // namespace std { // template class initializer_list; // } // struct A {}; @@ -8789,7 +9026,7 @@ bh.assertProblem("xl;", -1); } - // void f(int); + // constexpr int f(int); // enum class X {e1, e2= e1+2, e3}; // enum class Y {e1, e2= f(e1)+2, e3}; // enum A {e1, e2= e1+2, e3}; @@ -8811,6 +9048,52 @@ parseAndCheckBindings(); } + // template struct B {}; + // template <> + // struct B { + // void waldo(); + // }; + // typedef char& one; + // void test() { + // B b; + // b.waldo(); + // } + public void testSizeofReference_397342() throws Exception { + parseAndCheckBindings(); + } + + // struct A { + // char a[100]; + // }; + // struct B { + // A& b; + // }; + // A* p; + public void testSizeofStructWithReferenceField_397342() throws Exception { + BindingAssertionHelper bh = getAssertionHelper(); + IASTName nameB = bh.findName("B"); + IASTName namep = bh.findName("p"); + ICPPClassType B = (ICPPClassType) nameB.resolveBinding(); + IPointerType ptrToA = (IPointerType) ((ICPPVariable) namep.resolveBinding()).getType(); + long pointerSize = SizeofCalculator.getSizeAndAlignment(ptrToA, namep).size; + long BSize = SizeofCalculator.getSizeAndAlignment(B, nameB).size; + assertEquals(pointerSize, BSize); + } + + // template struct B {}; + // template <> + // struct B { + // void waldo(); + // }; + // typedef char& one; + // void test() { + // B b; + // b.waldo(); + // } + public void testAlignof_451082() throws Exception { + parseAndCheckBindings(); + } + // void f(int); // void f(unsigned int); // void test() { @@ -10094,7 +10377,7 @@ assertInstance(sDefinition, ICPPASTCompositeTypeSpecifier.class); assertTrue(((ICPPASTCompositeTypeSpecifier)sDefinition).isFinal()); } - + // struct S { // template // void foo(T t) final { @@ -10134,6 +10417,16 @@ public void testFinalParameter() throws Exception { parseAndCheckBindings(); } + + // struct S __final {}; + // struct T { void foo() __final; }; + public void testFinalGccExtension_442457() throws Exception { + BindingAssertionHelper bh = getAssertionHelper(); + ICPPClassType s = bh.assertNonProblem("S"); + assertTrue(s.isFinal()); + ICPPMethod foo = bh.assertNonProblem("foo"); + assertTrue(foo.isFinal()); + } // struct S1 {}; // S1 s1; @@ -10165,7 +10458,7 @@ // template struct A {}; // template <> // struct A { - // typedef int type; + // typedef int type; // }; // struct S {}; // const bool b = __is_base_of(S, int); @@ -10174,6 +10467,44 @@ parseAndCheckBindings(getAboveComment(), CPP, true); } + // template + // struct integral_constant { + // static constexpr T value = v; + // typedef integral_constant type; + // }; + // + // typedef integral_constant true_type; + // + // typedef integral_constant false_type; + // + // template + // struct is_base_of : public integral_constant {}; + // + // template + // struct enable_if {}; + // + // template + // struct enable_if { + // typedef T type; + // }; + // + // template + // using EnableIfIsBaseOf = + // typename enable_if::value, int>::type; + // + // class A {}; + // + // template + // class B {}; + // + // template = 0> + // using Waldo = B; + // + // Waldo c; + public void testIsBaseOf_446094() throws Exception { + parseAndCheckBindings(getAboveComment(), CPP, true); + } + // struct Bool { Bool(bool); }; // struct Char { Char(char); }; // struct Short { Short(short); }; @@ -10328,38 +10659,6 @@ assertEquals(1 /*true */, var.getInitialValue().numericalValue().longValue()); } - // template struct B{}; - // template <> - // struct B { - // void waldo(); - // }; - // typedef char& one; - // int main() { - // B b; - // b.waldo(); - // } - public void testSizeofReference_397342() throws Exception { - parseAndCheckBindings(); - } - - // struct A { - // char a[100]; - // }; - // struct B { - // A& b; - // }; - // A* p; - public void testSizeofStructWithReferenceField_397342() throws Exception { - BindingAssertionHelper bh = getAssertionHelper(); - IASTName nameB = bh.findName("B"); - IASTName namep = bh.findName("p"); - ICPPClassType B = (ICPPClassType) nameB.resolveBinding(); - IPointerType ptrToA = (IPointerType) ((ICPPVariable) namep.resolveBinding()).getType(); - long pointerSize = SizeofCalculator.getSizeAndAlignment(ptrToA, namep).size; - long BSize = SizeofCalculator.getSizeAndAlignment(B, nameB).size; - assertEquals(pointerSize, BSize); - } - // namespace NS { // class Enclosing { // class Inner {}; @@ -10513,15 +10812,15 @@ public void testUnderlyingTypeBuiltin_411196() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); - assertSameType((ITypedef) helper.assertNonProblem("short1_type"), CPPVisitor.SHORT_TYPE); - assertSameType((ITypedef) helper.assertNonProblem("short2_type"), CPPVisitor.SHORT_TYPE); + assertSameType((ITypedef) helper.assertNonProblem("short1_type"), CPPBasicType.SHORT); + assertSameType((ITypedef) helper.assertNonProblem("short2_type"), CPPBasicType.SHORT); - assertSameType((ITypedef) helper.assertNonProblem("scoped_type"), CPPVisitor.INT_TYPE); + assertSameType((ITypedef) helper.assertNonProblem("scoped_type"), CPPBasicType.INT); - assertSameType((ITypedef) helper.assertNonProblem("unsigned_type"), CPPVisitor.UNSIGNED_INT); - assertSameType((ITypedef) helper.assertNonProblem("int_type"), CPPVisitor.INT_TYPE); - assertSameType((ITypedef) helper.assertNonProblem("ulong_type"), CPPVisitor.UNSIGNED_LONG); - assertSameType((ITypedef) helper.assertNonProblem("loong_type"), CPPVisitor.LONG_TYPE); + assertSameType((ITypedef) helper.assertNonProblem("unsigned_type"), CPPBasicType.UNSIGNED_INT); + assertSameType((ITypedef) helper.assertNonProblem("int_type"), CPPBasicType.INT); + assertSameType((ITypedef) helper.assertNonProblem("ulong_type"), CPPBasicType.UNSIGNED_LONG); + assertSameType((ITypedef) helper.assertNonProblem("loong_type"), CPPBasicType.LONG); } // namespace A { @@ -10721,4 +11020,43 @@ ICPPFunction operator = helper.assertNonProblem("operator()"); assertEquals(operator, call2.getOverload()); } + + // void f(int &&a); + public void testRValueReferenceSignature_427856() throws Exception { + IASTTranslationUnit tu = parseAndCheckBindings(); + IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0]; + isParameterSignatureEqual(sd.getDeclarators()[0], "(int&&)"); + } + + // constexpr int waldo1 = 42; + // constexpr auto waldo2 = 43; + public void testConstexprVariableIsConst_451091() throws Exception { + BindingAssertionHelper helper = getAssertionHelper(); + ICPPVariable waldo1 = helper.assertNonProblem("waldo1"); + ICPPVariable waldo2 = helper.assertNonProblem("waldo2"); + // constexpr on a variable *should* make it const + assertSameType(waldo1.getType(), CommonTypes.constInt); + assertSameType(waldo2.getType(), CommonTypes.constInt); + } + + // constexpr int waldo1(); + // constexpr int (*waldo2())(int); + // struct S { constexpr int waldo3(); }; + public void testTypeOfConstexprFunction_451090() throws Exception { + BindingAssertionHelper helper = getAssertionHelper(); + ICPPFunction waldo1 = helper.assertNonProblem("waldo1"); + ICPPFunction waldo2 = helper.assertNonProblem("waldo2"); + ICPPFunction waldo3 = helper.assertNonProblem("waldo3"); + // constexpr on a function *should not* make its return type const + assertSameType(waldo1.getType().getReturnType(), CommonTypes.int_); + assertSameType(waldo2.getType().getReturnType(), + new CPPPointerType(new CPPFunctionType(CommonTypes.int_, new IType[]{ CommonTypes.int_ }))); + // constexpr on a method *should not* make the method const + assertSameType(waldo3.getType(), new CPPFunctionType(CommonTypes.int_, new IType[]{})); + } + + // void waldo() noexcept; + public void testASTCopyForNoexceptDefault_bug456207() throws Exception { + parseAndCheckBindings(); + } } diff -Nru eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java --- eclipse-cdt-8.5.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java 2014-09-17 20:29:37.000000000 +0000 +++ eclipse-cdt-8.6.0/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java 2015-02-11 19:19:10.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2014 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 @@ -128,14 +128,6 @@ return parseAndCheckBindings(code, CPP); } - protected IASTTranslationUnit parseAndCheckImplicitNameBindings() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, true); - NameCollector col = new NameCollector(true /* Visit implicit names */); - tu.accept(col); - assertNoProblemBindings(col); - return tu; - } - protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException { String code= getAboveComment(); return new BindingAssertionHelper(code, true); @@ -395,22 +387,6 @@ assertSame(f2, f1); } - // template < class T > void f (T); - // void main() { - // f(1); - // } - public void testTemplateFunctionImplicitInstantiation() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), CPP); - NameCollector col = new NameCollector(); - tu.accept(col); - - ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); - IFunction f2 = (IFunction) col.getName(5).resolveBinding(); - - assertTrue(f2 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance) f2).getTemplateDefinition(), f1); - } - // template < class T > void f(T); // #1 // template < class T > void f(T*); // #2 // template < class T > void f(const T*); // #3 @@ -2269,6 +2245,35 @@ bh.assertNonProblem("make_pair(1", 9, ICPPFunction.class); } + // template < class T > void f (T); + // void main() { + // f(1); + // } + public void testFunctionTemplateImplicitInstantiation() throws Exception { + IASTTranslationUnit tu = parse(getAboveComment(), CPP); + NameCollector col = new NameCollector(); + tu.accept(col); + + ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); + IFunction f2 = (IFunction) col.getName(5).resolveBinding(); + + assertTrue(f2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance) f2).getTemplateDefinition(), f1); + } + + // template + // int waldo(T (*function)()); + // + // template + // int waldo(T (*function)(U)); + // + // void test() { + // waldo(+[]() {}); + // } + public void testFunctionTemplateWithLambdaArgument_443361() throws Exception { + parseAndCheckBindings(); + } + // template // struct A {}; // @@ -7041,6 +7046,31 @@ assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint); } + // template + // struct A { + // typedef void (T::*func)(); + // }; + // + // template + // struct B { + // template ::func U> + // class C {}; + // + // template ::func U> + // using Waldo = C; + // }; + // + // struct D { + // void m(); + // }; + // + // void test() { + // B::Waldo<&D::m>(); + // } + public void testTemplatedAliasWithPointerToMember_448785() throws Exception { + parseAndCheckBindings(); + } + // namespace NS { // template // struct S { @@ -8531,4 +8561,112 @@ public void testConstexprFunctionCallWithNonConstexprArguments_429891() throws Exception { parseAndCheckBindings(); } + + // template class A {}; + // template class B {}; + // const int D = 4; + // + // // Type template parameter + // template > + // struct C1 {}; + // C1<> c1; + // + // // Template template parameter + // template