1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-08-25 15:20:09 -04:00
commit 2485747522
76 changed files with 1277 additions and 818 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2011 Red Hat Inc.
* Copyright (c) 2009, 2012 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,6 +7,7 @@
*
* Contributors:
* Red Hat Inc. - initial API and implementation
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.autotools.core.configure;
@ -16,8 +17,9 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.cdt.autotools.core.AutotoolsOptionConstants;
import org.eclipse.osgi.util.TextProcessor;
import org.eclipse.cdt.autotools.core.AutotoolsOptionConstants;
public class AutotoolsConfiguration implements IAConfiguration {
@ -57,11 +59,11 @@ public class AutotoolsConfiguration implements IAConfiguration {
}
public String getDescription() {
return ConfigureMessages.getConfigureDescription(transformedName);
return TextProcessor.process(ConfigureMessages.getConfigureDescription(transformedName));
}
public String getToolTip() {
return ConfigureMessages.getConfigureTip(transformedName);
return TextProcessor.process(ConfigureMessages.getConfigureTip(transformedName));
}
}

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.autotools.tests.editors.EditorTests;
import junit.framework.Test;
import junit.framework.TestSuite;
/** On Windows requires either Cygwin or MinGW to be in PATH */
public class AllAutotoolsTests {
public static Test suite() {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007, 2009 Red Hat Inc..
* Copyright (c) 2006, 2012 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,6 +7,7 @@
*
* Contributors:
* Red Hat Incorporated - initial API and implementation
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.autotools.ui.actions;
@ -14,6 +15,8 @@ import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.osgi.util.TextProcessor;
public class InvokeMessages {
private static final String BUNDLE_NAME = InvokeMessages.class.getName();
@ -32,7 +35,7 @@ public class InvokeMessages {
*/
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
return TextProcessor.process(RESOURCE_BUNDLE.getString(key));
} catch (MissingResourceException e) {
return '!' + key + '!';
}
@ -47,7 +50,7 @@ public class InvokeMessages {
* @return the resource bundle message
*/
public static String getFormattedString(String key, String[] args) {
return MessageFormat.format(getString(key), (Object[])args);
return TextProcessor.process(MessageFormat.format(getString(key), (Object[])args));
}
}

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
<version>8.2.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<version>7.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.make.core.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>false</useUIHarness>
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
<includes>
<include>**/AutomatedIntegrationSuite.*</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -96,10 +96,7 @@ public class GCCScannerInfoConsoleParserTests extends BaseBOPConsoleParserTests
assertTrue(sumIncludes.contains("//server6/include")); //$NON-NLS-1$
assertTrue(sumIncludes.contains("/multiline/dir")); //$NON-NLS-1$
assertTrue(sumIncludes.contains("multiline2")); //$NON-NLS-1$
// Fails consistently
if (System.getProperty("cdt.skip.known.test.failures") == null) {
assertTrue(sumIncludes.contains("multiline3")); //$NON-NLS-1$
}
assertTrue(sumIncludes.size() == 26);
}
}

View file

@ -94,8 +94,7 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
*/
@Override
public boolean processLine(String line) {
line= line.trim();
if (line.length() == 0) {
if (line.trim().length() == 0) {
return false;
}
boolean rc = false;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2011 Intel Corporation and others.
* Copyright (c) 2007, 2012 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors:
* Intel Corporation - initial API and implementation
* James Blackbrun (Broadcom Corp.)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.wizards;
@ -31,6 +32,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osgi.util.TextProcessor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@ -140,7 +142,7 @@ public class CDTConfigWizardPage extends WizardPage {
tv.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return element == null ? EMPTY_STR : ((CfgHolder)element).getName();
return element == null ? EMPTY_STR : TextProcessor.process(((CfgHolder)element).getName());
}
@Override
public Image getImage(Object element) { return IMG_CONFIG; }

View file

@ -17,7 +17,8 @@ extension.name.Marker = Code Analysis Problem
category.name.ProgrammingErrors = Potential Programming Problems
category.name.CodeStyle = Coding Style
category.name.CompilerErrors = Syntax and Semantic Errors
extension-point.name.CodeAnalysis = Code Analysis Checkers
codeAnalysisCheckersExtensionPoint = Code Analysis Checkers
checkerEnablementExtensionPoint = Verification of Checker Enablement
marker.semanticError = Semantic Error
category.name.Security = Security Vulnerabilities

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="checkers" name="%extension-point.name.CodeAnalysis" schema="schema/checkers.exsd"/>
<extension-point id="checkerEnablement" name="Verification of checker enablement" schema="schema/checkerEnablement.exsd"/>
<extension-point id="checkers" name="%codeAnalysisCheckersExtensionPoint" schema="schema/checkers.exsd"/>
<extension-point id="checkerEnablement" name="%checkerEnablementExtensionPoint" schema="schema/checkerEnablement.exsd"/>
<extension
id="codanBuilder"

View file

@ -18,8 +18,8 @@ CodeAnalysisPreferencesBuild.name = Launching
category.name = Code Analysis
command.name = Run Code Analysis
view.name = Problem Details
extension-point.name = Codan Problem Details
extension-point.name.codamMarkerResolution = Codan Marker Resolution
codanProblemDetailsExtensionPoint = Codan Problem Details
codanMarkerResolutionExtensionPoint = Codan Marker Resolution
markerTypeCategory.name = Code Analysis Problems
markerGrouping.label = Code Analysis Problem Type
markerGroupingEntry.category.Unknown = Unknown

View file

@ -71,8 +71,8 @@
name="%view.name">
</view>
</extension>
<extension-point id="codanProblemDetails" name="%extension-point.name" schema="schema/codanProblemDetails.exsd"/>
<extension-point id="codanMarkerResolution" name="%extension-point.name.codamMarkerResolution" schema="schema/codanMarkerResolution.exsd"/>
<extension-point id="codanProblemDetails" name="%codanProblemDetailsExtensionPoint" schema="schema/codanProblemDetails.exsd"/>
<extension-point id="codanMarkerResolution" name="%codanMarkerResolutionExtensionPoint" schema="schema/codanMarkerResolution.exsd"/>
<!--
<extension
point="org.eclipse.ui.bindings">

View file

@ -12,15 +12,14 @@ import junit.framework.TestSuite;
public class AllTests extends TestSuite {
public static Test suite() throws Exception {
final AllTests suite = new AllTests();
suite.addTest(org.eclipse.cdt.autotools.tests.AllAutotoolsTests.suite()); // Works with MinGW but not Cygwin
suite.addTest(org.eclipse.cdt.autotools.tests.AllAutotoolsTests.suite());
// // There are intermittent failures in these tests. No pattern to failures. Seems like indexer is interrupted
if (System.getProperty("cdt.skip.known.test.failures") == null) { //$NON-NLS-1$
suite.addTest(org.eclipse.cdt.codan.core.test.AutomatedIntegrationSuite.suite());
suite.addTest(org.eclipse.cdt.core.lrparser.tests.LRParserTestSuite.suite());
suite.addTest(org.eclipse.cdt.core.parser.xlc.tests.suite.XlcTestSuite.suite());
}
suite.addTest(org.eclipse.cdt.core.parser.upc.tests.UPCParserTestSuite.suite());
}
suite.addTest(org.eclipse.cdt.core.suite.AutomatedIntegrationSuite.suite());
// These tests fail intermittently due to gdb not shutting down and thus

View file

@ -938,14 +938,12 @@ public class ErrorParserFileMatchingTest extends TestCase {
return;
}
// Consistently fails, and, yes, I do have Cygwin in my PATH
if (System.getProperty("cdt.skip.known.test.failures") != null) { //$NON-NLS-1$
return;
}
assertTrue("usrIncludeWindowsPath=["+usrIncludeWindowsPath+"]",
usrIncludeWindowsPath.charAt(1)==IPath.DEVICE_SEPARATOR);
java.io.File file = new java.io.File(usrIncludeWindowsPath + "\\" + fileName);
assertTrue("File " + file + " does not exist, check your cygwin installation", file.exists());
ResourceHelper.createLinkedFolder(fProject, "include", usrIncludeWindowsPath);
parseOutput(cygwinFolder+fileName+":1:error");

View file

@ -105,7 +105,7 @@ public class AST2BaseTest extends BaseTestCase {
private static Map<String, String> getGnuMap() {
Map<String, String> map= new HashMap<String, String>();
map.put("__GNUC__", "4");
map.put("__GNUC_MINOR__", "5");
map.put("__GNUC_MINOR__", "7");
map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8");
return map;

View file

@ -5988,4 +5988,27 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testSFINAE_b() throws Exception {
parseAndCheckBindings();
}
// template<typename T>
// struct is_pod {
// static const bool value = __is_pod(T);
// };
//
// template <bool, typename = void>
// struct enable_if {};
//
// template <typename T>
// struct enable_if<true, T> {
// typedef T type;
// };
//
// template <typename T>
// void f(typename enable_if<is_pod<T>::value>::type* = 0);
//
// void test() {
// f<int>();
// }
public void testIsPOD_367993() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
}

View file

@ -1,122 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011 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.parser.tests.ast2;
import java.io.IOException;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.parser.ParserException;
/**
* Tests for ClassTypeHelper class.
*/
public class ClassTypeHelperTests extends AST2BaseTest {
public ClassTypeHelperTests() {
}
public ClassTypeHelperTests(String name) {
super(name);
}
public static TestSuite suite() {
return suite(ClassTypeHelperTests.class);
}
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
String code= getAboveComment();
return new BindingAssertionHelper(code, true);
}
// struct A {
// A(const A& a);
// };
//
// class B {
// public:
// B();
// int x;
// A* y;
// const A& z;
// static A s;
// };
//
// class C {
// public:
// A a;
// };
public void testHasTrivialCopyCtor() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.hasTrivialCopyCtor(classA, null));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertTrue(ClassTypeHelper.hasTrivialCopyCtor(classB, null));
ICPPClassType classC = helper.assertNonProblem("C {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.hasTrivialCopyCtor(classC, null));
}
// struct A {
// ~A();
// };
//
// class B {
// public:
// B();
// B(const B& a);
// int x;
// B* y;
// const B& z;
// static A s;
// };
//
// class C {
// public:
// A a;
// };
public void testHasTrivialDestructor() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.hasTrivialDestructor(classA, null));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertTrue(ClassTypeHelper.hasTrivialDestructor(classB, null));
ICPPClassType classC = helper.assertNonProblem("C {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.hasTrivialDestructor(classC, null));
}
// struct A {
// virtual void m();
// };
//
// class B {
// public:
// B();
// B(const B& a);
// void m();
// int x;
// B* y;
// const B& z;
// };
//
// class C : public A {
// };
public void testIsPolymorphic() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertTrue(ClassTypeHelper.isPolymorphic(classA));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.isPolymorphic(classB));
ICPPClassType classC = helper.assertNonProblem("C", 1, ICPPClassType.class);
assertTrue(ClassTypeHelper.isPolymorphic(classC));
}
}

View file

@ -30,7 +30,7 @@ public class DOMParserTestSuite extends TestCase {
suite.addTest(ASTCPPSpecDefectTests.suite());
suite.addTest(AST2CPPImplicitNameTests.suite());
suite.addTest(AST2TemplateTests.suite());
suite.addTest(ClassTypeHelperTests.suite());
suite.addTest(TypeTraitsTests.suite());
suite.addTestSuite(QuickParser2Tests.class);
suite.addTest(CompleteParser2Tests.suite());
suite.addTest(DOMLocationTests.suite());

View file

@ -426,7 +426,7 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
// b= __is_polymorphic (int);
// b= __is_union (int);
// }
public void testTypetraits_Bug342683() throws Exception {
public void testTypeTraits_Bug342683() throws Exception {
parseGPP(getAboveComment());
}
}

View file

@ -0,0 +1,239 @@
/*******************************************************************************
* Copyright (c) 2011, 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import java.io.IOException;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits;
import org.eclipse.cdt.internal.core.parser.ParserException;
/**
* Tests for ClassTypeHelper class.
*/
public class TypeTraitsTests extends AST2BaseTest {
public TypeTraitsTests() {
}
public TypeTraitsTests(String name) {
super(name);
}
public static TestSuite suite() {
return suite(TypeTraitsTests.class);
}
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
String code= getAboveComment();
return new BindingAssertionHelper(code, true);
}
// struct A {
// A(const A& a);
// };
//
// class B {
// public:
// B();
// int x;
// A* y;
// const A& z;
// static A s;
// };
//
// class C {
// public:
// A a;
// };
public void testHasTrivialCopyCtor() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertFalse(TypeTraits.hasTrivialCopyCtor(classA, null));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertTrue(TypeTraits.hasTrivialCopyCtor(classB, null));
ICPPClassType classC = helper.assertNonProblem("C {", 1, ICPPClassType.class);
assertFalse(TypeTraits.hasTrivialCopyCtor(classC, null));
}
// struct A {
// ~A();
// };
//
// class B {
// public:
// B();
// B(const B& a);
// int x;
// B* y;
// const B& z;
// static A s;
// };
//
// class C {
// public:
// A a;
// };
public void testHasTrivialDestructor() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertFalse(TypeTraits.hasTrivialDestructor(classA, null));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertTrue(TypeTraits.hasTrivialDestructor(classB, null));
ICPPClassType classC = helper.assertNonProblem("C {", 1, ICPPClassType.class);
assertFalse(TypeTraits.hasTrivialDestructor(classC, null));
}
// struct A {
// virtual void m();
// };
//
// class B {
// public:
// B();
// B(const B& a);
// void m();
// int x;
// B* y;
// const B& z;
// };
//
// class C : public A {
// };
public void testIsPolymorphic() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertTrue(TypeTraits.isPolymorphic(classA, null));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isPolymorphic(classB, null));
ICPPClassType classC = helper.assertNonProblem("C", 1, ICPPClassType.class);
assertTrue(TypeTraits.isPolymorphic(classC, null));
}
// struct A {
// A* a;
// int b;
// A(A* a, int b);
// A(A& a);
// ~A();
// };
//
// class B : public A {
// static int c;
// void m(A* a);
// };
//
// class C : public A {
// int c;
// };
//
// struct D {
// C c;
// };
//
// struct E : public C {
// };
//
// struct F : public B {
// virtual ~F();
// };
//
// struct G {
// int a;
// private:
// int b;
// };
//
// struct H {
// int& a;
// };
public void testIsStandardLayout() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertTrue(TypeTraits.isStandardLayout(classA, null));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertTrue(TypeTraits.isStandardLayout(classB, null));
ICPPClassType classC = helper.assertNonProblem("C :", 1, ICPPClassType.class);
assertFalse(TypeTraits.isStandardLayout(classC, null));
ICPPClassType classD = helper.assertNonProblem("D {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isStandardLayout(classD, null));
ICPPClassType classE = helper.assertNonProblem("E :", 1, ICPPClassType.class);
assertFalse(TypeTraits.isStandardLayout(classE, null));
ICPPClassType classF = helper.assertNonProblem("F :", 1, ICPPClassType.class);
assertFalse(TypeTraits.isStandardLayout(classF, null));
ICPPClassType classG = helper.assertNonProblem("G {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isStandardLayout(classG, null));
ICPPClassType classH = helper.assertNonProblem("H {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isStandardLayout(classH, null));
}
// struct A {
// A* a;
// int b;
// A(char* s);
// A(const A& a, int b);
// A& operator =(const A& a, A* b);
// };
//
// class B : public A {
// A a;
// };
//
// struct C {
// C(char* s = 0);
// };
//
// struct D {
// D(const D& a, int b = 1);
// };
//
// struct E {
// E& operator =(const E& a, E* b = nullptr);
// };
//
// struct F {
// ~F();
// };
//
// struct G {
// C c;
// };
//
// struct H : public C {
// };
//
// struct I {
// virtual void m();
// };
public void testIsTrivial() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertTrue(TypeTraits.isTrivial(classA, null));
ICPPClassType classB = helper.assertNonProblem("B :", 1, ICPPClassType.class);
assertTrue(TypeTraits.isTrivial(classB, null));
ICPPClassType classC = helper.assertNonProblem("C {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isTrivial(classC, null));
ICPPClassType classD = helper.assertNonProblem("D {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isTrivial(classD, null));
ICPPClassType classE = helper.assertNonProblem("E {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isTrivial(classE, null));
ICPPClassType classF = helper.assertNonProblem("F {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isTrivial(classF, null));
ICPPClassType classG = helper.assertNonProblem("G {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isTrivial(classG, null));
ICPPClassType classH = helper.assertNonProblem("H :", 1, ICPPClassType.class);
assertFalse(TypeTraits.isTrivial(classH, null));
ICPPClassType classI = helper.assertNonProblem("I {", 1, ICPPClassType.class);
assertFalse(TypeTraits.isTrivial(classI, null));
}
}

View file

@ -108,7 +108,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
public class IndexBugsTests extends BaseTestCase {
private static final int INDEXER_TIMEOUT_SEC = 20;
private ICProject fCProject;
protected IIndex fIndex;

View file

@ -94,7 +94,6 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
// #define FUNC() void bar()
// #define FUNC2(A) void baz()
// #include "header.h"
//
// OBJ {}
@ -207,7 +206,6 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
IBinding b8= getBindingFromASTName("testCall( /*8*/", 8);
}
// template<typename T1>
// class A {};
//
@ -351,7 +349,6 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
getBindingFromASTName("fooovr('", 6);
}
// // header
// class Base {
// public:
@ -454,7 +451,6 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
IBinding b1= getBindingFromASTName("id(6", 2);
}
// void func1(void);
// #include "header.h"

View file

@ -468,7 +468,7 @@ public class IndexCompositeTests extends BaseTestCase {
* Convenience class for setting up projects.
*/
class ProjectBuilder {
private static final int INDEXER_TIMEOUT_SEC = 5;
private static final int INDEXER_TIMEOUT_SEC = 10;
private final String name;
private final boolean cpp;
private List dependencies = new ArrayList();

View file

@ -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.pdom.tests;
@ -39,7 +39,7 @@ public class PDOMLocationTests extends BaseTestCase {
@Override
protected void setUp() throws Exception {
cproject= CProjectHelper.createCCProject("PDOMLocationTests"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
cproject= CProjectHelper.createCCProject("PDOMLocationTests" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
super.setUp();
}
@ -66,11 +66,11 @@ public class PDOMLocationTests extends BaseTestCase {
Set<String> externals= new HashSet();
externals.addAll(Arrays.asList(linuxExternals));
if(Platform.getOS().equals("win32")) {
if (Platform.getOS().equals("win32")) {
externals.addAll(Arrays.asList(winExternals));
}
for(String ext : externals) {
for (String ext : externals) {
IIndexFileLocation loc = IndexLocationFactory.getExternalIFL(ext);
String raw = converter.toInternalFormat(loc);
IIndexFileLocation roundtrip = converter.fromInternalFormat(raw);

View file

@ -55,9 +55,9 @@ public class PDOMProviderTests extends PDOMTestBase {
final File tempPDOM= File.createTempFile("foo", "bar");
{
ICProject cproject= CProjectHelper.createCCProject("foo"+System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
index.acquireReadLock();
@ -76,9 +76,9 @@ public class PDOMProviderTests extends PDOMTestBase {
}
final URI baseURI= new File("c:/ExternalSDK/").toURI();
final ICProject cproject2= CProjectHelper.createCCProject("bar"+System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
final ICProject cproject2= CProjectHelper.createCCProject("bar" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n");
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(
@ -127,9 +127,9 @@ public class PDOMProviderTests extends PDOMTestBase {
final File tempPDOM= File.createTempFile("foo", "bar");
{
ICProject cproject= CProjectHelper.createCCProject("foo"+System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
index.acquireReadLock();
@ -147,14 +147,14 @@ public class PDOMProviderTests extends PDOMTestBase {
CProjectHelper.delete(cproject);
}
final ICProject cproject3= CProjectHelper.createCCProject("bar"+System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
final ICProject cproject3= CProjectHelper.createCCProject("bar" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject3.getProject(), new Path("/source.cpp"), "namespace Y { class A {}; }\n\n");
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
final URI baseURI= new File("c:/ExternalSDK/").toURI();
final ICProject cproject2= CProjectHelper.createCCProject("baz"+System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
final ICProject cproject2= CProjectHelper.createCCProject("baz" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n");
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(
@ -241,21 +241,18 @@ public class PDOMProviderTests extends PDOMTestBase {
}
}
/*
* see bugzilla 178998
*/
public void testVersionMismatchOfExternalPDOM() throws Exception {
public void testVersionMismatchOfExternalPDOM_178998() throws Exception {
final File tempPDOM= File.createTempFile("foo", "bar");
{
ICProject cproject= CProjectHelper.createCCProject("foo"+System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
ResourceContainerRelativeLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject());
CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, tempPDOM, cvr);
CProjectHelper.delete(cproject);
// mimic a pdom with superceded version
// Mimic a PDOM with superseded version.
WritablePDOM wpdom= new WritablePDOM(tempPDOM, cvr, LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
wpdom.acquireWriteLock();
try {
@ -267,9 +264,9 @@ public class PDOMProviderTests extends PDOMTestBase {
}
final URI baseURI= new File("c:/ExternalSDK/").toURI();
final ICProject cproject2= CProjectHelper.createCCProject("baz"+System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
final ICProject cproject2= CProjectHelper.createCCProject("baz" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n");
CCorePlugin.getIndexManager().joinIndexer(3000, npm());
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(
@ -302,7 +299,7 @@ public class PDOMProviderTests extends PDOMTestBase {
setExpectedNumberOfLoggedNonOKStatusObjects(1); // (this applies to the entire test duration)
for (int i= 0; i < 3; i++) {
// try several times in order to test the status is logged only once
// Try several times in order to test the status is logged only once.
ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(cproject2.getProject(), false);
assertEquals(0, ipm.getProvidedIndexFragments(pd.getActiveConfiguration(), -1).length);
}

View file

@ -33,6 +33,7 @@ import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@ -60,16 +61,17 @@ public class PDOMSearchTest extends PDOMTestBase {
@Override
protected void setUp() throws Exception {
if (pdom == null) {
ICProject project = createProject("searchTests", true);
pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(project);
}
project = createProject("searchTests", true);
pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
pdom.acquireReadLock();
}
@Override
protected void tearDown() throws Exception {
pdom.releaseReadLock();
if (project != null) {
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
}
}
/**

View file

@ -57,7 +57,7 @@ import org.eclipse.ui.wizards.datatransfer.ImportOperation;
public class PDOMTestBase extends BaseTestCase {
protected static final IProgressMonitor PROGRESS = new NullProgressMonitor();
static IPath rootPath = new Path("resources/pdomtests");
private String projectName= null;
private String projectName;
protected ICProject createProject(String folderName) throws CoreException {
return createProject(folderName, false);

View file

@ -18,14 +18,12 @@ import junit.framework.TestSuite;
/**
* @author Doug Schaefer
*
*/
public class PDOMTests extends TestSuite {
public static Test suite() {
TestSuite suite = new PDOMTests();
suite.addTest(DBTest.suite());
suite.addTest(DBPropertiesTests.suite());
suite.addTest(PDOMCBugsTest.suite());
@ -61,5 +59,4 @@ public class PDOMTests extends TestSuite {
return suite;
}
}

View file

@ -457,7 +457,7 @@ public class ResourceHelper {
*/
public static IFolder createLinkedFolder(IProject project, String folderLink, IPath realFolder) throws CoreException {
IFolder folder = project.getFolder(folderLink);
folder.createLink(realFolder, IResource.REPLACE, null);
folder.createLink(realFolder, IResource.REPLACE | IResource.ALLOW_MISSING_LOCAL, null);
Assert.assertTrue(folder.exists());
resourcesCreated.add(folder);
return folder;

View file

@ -45,6 +45,7 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
public class BaseTestCase extends TestCase {
protected static final int INDEXER_TIMEOUT_SEC = 10;
private boolean fExpectFailure;
private int fBugNumber;
private int fExpectedLoggedNonOK;
@ -290,12 +291,12 @@ public class BaseTestCase extends TestCase {
public static void waitForIndexer(ICProject project) throws InterruptedException {
final PDOMManager indexManager = CCoreInternals.getPDOMManager();
assertTrue(indexManager.joinIndexer(10000, npm()));
assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()));
long waitms= 1;
while (waitms < 2000 && !indexManager.isProjectRegistered(project)) {
Thread.sleep(waitms);
waitms *= 2;
}
assertTrue(indexManager.joinIndexer(10000, npm()));
assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()));
}
}

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
@ -204,7 +205,8 @@ public class ASTCache {
ASTRunnable astRunnable) {
IIndex index;
try {
index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject());
index = CCorePlugin.getIndexManager().getIndex(tUnit.getCProject(),
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
index.acquireReadLock();
} catch (CoreException e) {
return e.getStatus();

View file

@ -121,7 +121,8 @@ public class CModelBuilder2 implements IContributedModelBuilder {
@Override
public void parse(boolean quickParseMode) throws Exception {
final IIndexManager indexManager= CCorePlugin.getIndexManager();
IIndex index= indexManager.getIndex(fTranslationUnit.getCProject());
IIndex index = indexManager.getIndex(fTranslationUnit.getCProject(),
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
try {
if (index != null) {

View file

@ -20,9 +20,9 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
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.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits;
/**
* A collection of static methods related to types.
@ -48,8 +48,8 @@ public class TypeHelper {
if (type instanceof ICompositeType) {
if (type instanceof ICPPClassType) {
ICPPClassType classType = ((ICPPClassType) type);
if (!ClassTypeHelper.hasTrivialCopyCtor(classType, ast) ||
!ClassTypeHelper.hasTrivialDestructor(classType, ast)) {
if (!TypeTraits.hasTrivialCopyCtor(classType, ast) ||
!TypeTraits.hasTrivialDestructor(classType, ast)) {
return true;
}
}

View file

@ -112,6 +112,15 @@ public interface IIndexManager extends IPDOMManager {
*/
public static final int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200;
/**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index
* content provided via the ReadOnlyIndexFragmentProvider or ReadOnlyPDOMProvider, which is not
* disabled for the editor shall be included in the resulting index.
*
* @since 5.5
*/
public static final int ADD_EXTENSION_FRAGMENTS_EDITOR = 0x400;
/**
* Constant for indicating that there is no time out period for joining the indexer job.
* @see IIndexManager#joinIndexer(int, IProgressMonitor)

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IArrayType;
@ -73,6 +74,20 @@ public class SizeofCalculator {
private final IASTTranslationUnit ast;
/**
* Calculates size and alignment for the given type.
*
* @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 <code>null</code> if could not be calculated.
*/
public static SizeAndAlignment getSizeAndAlignment(IType type, IASTNode point) {
SizeofCalculator calc = point == null ?
getDefault() : ((ASTTranslationUnit) point.getTranslationUnit()).getSizeofCalculator();
return calc.sizeAndAlignment(type);
}
/**
* Returns the default instance of sizeof calculator. The default instance is not aware
* of the parser configuration and can only calculate sizes that are the same across all

View file

@ -11,29 +11,58 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_alignof;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_nothrow_constructor;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_nothrow_copy;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_trivial_assign;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_trivial_constructor;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_trivial_copy;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_trivial_destructor;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_virtual_destructor;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_abstract;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_class;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_empty;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_enum;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_literal_type;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_pod;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_polymorphic;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_standard_layout;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_trivial;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_union;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_sizeof;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_typeid;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_typeof;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTBinaryTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
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.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.ICPPASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits;
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
@ -201,7 +230,7 @@ public class Value implements IValue {
public static IValue evaluateBinaryExpression(final int op, final long v1, final long v2) {
try {
return create(combineBinary(op, v1, v2));
return create(applyBinaryOperator(op, v1, v2));
} catch (UnknownValueException e) {
}
return UNKNOWN;
@ -209,12 +238,101 @@ public class Value implements IValue {
public static IValue evaluateUnaryExpression(final int unaryOp, final long value) {
try {
return create(combineUnary(unaryOp, value));
return create(applyUnaryOperator(unaryOp, value));
} catch (UnknownValueException e) {
}
return UNKNOWN;
}
public static IValue evaluateUnaryTypeIdExpression(int operator, IType type, IASTNode point) {
try {
return create(applyUnaryTypeIdOperator(operator, type, point));
} catch (UnknownValueException e) {
}
return UNKNOWN;
}
public static IValue evaluateBinaryTypeIdExpression(IASTBinaryTypeIdExpression.Operator operator,
IType type1, IType type2, IASTNode point) {
try {
return create(applyBinaryTypeIdOperator(operator, type1, type2, point));
} catch (UnknownValueException e) {
}
return UNKNOWN;
}
private static long applyUnaryTypeIdOperator(int operator, IType type, IASTNode point) throws UnknownValueException{
switch (operator) {
case op_sizeof:
return getSizeAndAlignment(type, point).size;
case op_alignof:
return getSizeAndAlignment(type, point).alignment;
case op_typeid:
break; // TODO(sprigogin): Implement
case op_has_nothrow_copy:
break; // TODO(sprigogin): Implement
case op_has_nothrow_constructor:
break; // TODO(sprigogin): Implement
case op_has_trivial_assign:
break; // TODO(sprigogin): Implement
case op_has_trivial_constructor:
break; // TODO(sprigogin): Implement
case op_has_trivial_copy:
return !(type instanceof ICPPClassType) ||
TypeTraits.hasTrivialCopyCtor((ICPPClassType) type, point) ? 1 : 0;
case op_has_trivial_destructor:
break; // TODO(sprigogin): Implement
case op_has_virtual_destructor:
break; // TODO(sprigogin): Implement
case op_is_abstract:
return type instanceof ICPPClassType &&
TypeTraits.isAbstract((ICPPClassType) type, point) ? 1 : 0;
case op_is_class:
return type instanceof ICompositeType &&
((ICompositeType) type).getKey() != ICompositeType.k_union ? 1 : 0;
case op_is_empty:
break; // TODO(sprigogin): Implement
case op_is_enum:
return type instanceof IEnumeration ? 1 : 0;
case op_is_literal_type:
break; // TODO(sprigogin): Implement
case op_is_pod:
return TypeTraits.isPOD(type, point) ? 1 : 0;
case op_is_polymorphic:
return type instanceof ICPPClassType &&
TypeTraits.isPolymorphic((ICPPClassType) type, point) ? 1 : 0;
case op_is_standard_layout:
return TypeTraits.isStandardLayout(type, point) ? 1 : 0;
case op_is_trivial:
return type instanceof ICPPClassType &&
TypeTraits.isTrivial((ICPPClassType) type, point) ? 1 : 0;
case op_is_union:
return type instanceof ICompositeType &&
((ICompositeType) type).getKey() == ICompositeType.k_union ? 1 : 0;
case op_typeof:
break; // TODO(sprigogin): Implement
}
throw UNKNOWN_EX;
}
public static long applyBinaryTypeIdOperator(IASTBinaryTypeIdExpression.Operator operator,
IType type1, IType type2, IASTNode point) throws UnknownValueException {
switch (operator) {
case __is_base_of:
if (type1 instanceof ICPPClassType && type1 instanceof ICPPClassType) {
return ClassTypeHelper.isSubclass((ICPPClassType) type2, (ICPPClassType) type1) ? 1 : 0;
}
}
throw UNKNOWN_EX;
}
private static SizeAndAlignment getSizeAndAlignment(IType type, IASTNode point) throws UnknownValueException {
SizeAndAlignment sizeAndAlignment = SizeofCalculator.getSizeAndAlignment(type, point);
if (sizeAndAlignment == null)
throw UNKNOWN_EX;
return sizeAndAlignment;
}
/**
* Tests whether the value is a template parameter (or a parameter pack).
*
@ -348,19 +466,15 @@ public class Value implements IValue {
}
}
if (exp instanceof IASTTypeIdExpression) {
IASTTypeIdExpression typeIdEx = (IASTTypeIdExpression) exp;
switch (typeIdEx.getOperator()) {
case IASTTypeIdExpression.op_sizeof:
ASTTranslationUnit ast = (ASTTranslationUnit) typeIdEx.getTranslationUnit();
final IType type = ast.createType(typeIdEx.getTypeId());
if (type instanceof ICPPUnknownType)
return null;
SizeofCalculator calculator = ast.getSizeofCalculator();
SizeAndAlignment info = calculator.sizeAndAlignment(type);
if (info == null)
throw UNKNOWN_EX;
return info.size;
}
ASTTranslationUnit ast = (ASTTranslationUnit) exp.getTranslationUnit();
final IType type = ast.createType(((IASTTypeIdExpression) exp).getTypeId());
if (type instanceof ICPPUnknownType)
return null;
return applyUnaryTypeIdOperator(((IASTTypeIdExpression) exp).getOperator(), type, exp);
}
if (exp instanceof IASTBinaryTypeIdExpression) {
}
throw UNKNOWN_EX;
}
@ -422,10 +536,10 @@ public class Value implements IValue {
final Long value= evaluate(exp.getOperand(), maxdepth);
if (value == null)
return null;
return combineUnary(unaryOp, value);
return applyUnaryOperator(unaryOp, value);
}
private static long combineUnary(final int unaryOp, final long value) throws UnknownValueException {
private static long applyUnaryOperator(final int unaryOp, final long value) throws UnknownValueException {
switch (unaryOp) {
case IASTUnaryExpression.op_bracketedPrimary:
case IASTUnaryExpression.op_plus:
@ -470,10 +584,10 @@ public class Value implements IValue {
if (o2 == null)
return null;
return combineBinary(op, o1, o2);
return applyBinaryOperator(op, o1, o2);
}
private static long combineBinary(final int op, final long v1, final long v2)
private static long applyBinaryOperator(final int op, final long v1, final long v2)
throws UnknownValueException {
switch (op) {
case IASTBinaryExpression.op_multiply:

View file

@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others.
* Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -43,13 +43,9 @@ public class CPPASTTypeIdExpression extends ASTNode implements ICPPASTTypeIdExpr
@Override
public CPPASTTypeIdExpression copy(CopyStyle style) {
CPPASTTypeIdExpression copy = new CPPASTTypeIdExpression(op, typeId == null ? null
: typeId.copy(style));
copy.setOffsetAndLength(this);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
CPPASTTypeIdExpression copy =
new CPPASTTypeIdExpression(op, typeId == null ? null : typeId.copy(style));
return copy(copy, style);
}
@Override
@ -66,11 +62,11 @@ public class CPPASTTypeIdExpression extends ASTNode implements ICPPASTTypeIdExpr
@Override
public void setTypeId(IASTTypeId typeId) {
assertNotFrozen();
this.typeId = typeId;
if (typeId != null) {
typeId.setParent(this);
typeId.setPropertyInParent(TYPE_ID);
}
this.typeId = typeId;
if (typeId != null) {
typeId.setParent(this);
typeId.setPropertyInParent(TYPE_ID);
}
}
@Override

View file

@ -15,9 +15,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ARRAY;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import java.util.ArrayList;
import java.util.Collections;
@ -39,7 +36,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -60,8 +56,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
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.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.index.IIndex;
@ -101,8 +97,9 @@ public class ClassTypeHelper {
ObjectSet<IBinding> resultSet = new ObjectSet<IBinding>(2);
IASTDeclaration[] members = host.getCompositeTypeSpecifier().getMembers();
for (IASTDeclaration decl : members) {
while (decl instanceof ICPPASTTemplateDeclaration)
while (decl instanceof ICPPASTTemplateDeclaration) {
decl = ((ICPPASTTemplateDeclaration) decl).getDeclaration();
}
if (decl instanceof IASTSimpleDeclaration) {
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
@ -714,14 +711,66 @@ public class ClassTypeHelper {
}
}
private static final int KIND_DEFAULT_CTOR= 0;
private static final int KIND_COPY_CTOR= 1;
private static final int KIND_ASSIGNMENT_OP= 2;
private static final int KIND_DTOR= 3;
private static final int KIND_OTHER= 4;
public enum MethodKind {
DEFAULT_CTOR,
COPY_CTOR,
MOVE_CTOR,
COPY_ASSIGNMENT_OP,
MOVE_ASSIGNMENT_OP,
DTOR,
OTHER
}
public static MethodKind getMethodKind(ICPPClassType classType, ICPPMethod method) {
if (method instanceof ICPPConstructor) {
final List<IType> params= getTypesOfRequiredParameters(method);
if (params.isEmpty())
return MethodKind.DEFAULT_CTOR;
if (params.size() == 1) {
IType t= SemanticUtil.getNestedType(params.get(0), SemanticUtil.TDEF);
if (SemanticUtil.isVoidType(t))
return MethodKind.DEFAULT_CTOR;
ICPPReferenceType refToClass = getRefToClass(classType, t);
if (refToClass != null)
return refToClass.isRValueReference() ? MethodKind.MOVE_CTOR : MethodKind.COPY_CTOR;
}
return MethodKind.OTHER;
}
if (method.isDestructor())
return MethodKind.DTOR;
if (CharArrayUtils.equals(method.getNameCharArray(), OverloadableOperator.ASSIGN.toCharArray())) {
final List<IType> params= getTypesOfRequiredParameters(method);
if (params.size() == 1) {
IType t= params.get(0);
ICPPReferenceType refToClass = getRefToClass(classType, t);
if (refToClass != null)
return refToClass.isRValueReference() ? MethodKind.MOVE_ASSIGNMENT_OP : MethodKind.COPY_ASSIGNMENT_OP;
}
return MethodKind.OTHER;
}
return MethodKind.OTHER;
}
/**
* For implicit methods the exception specification is inherited, search it
* Returns types of method parameters that don't have defaults.
*/
private static List<IType> getTypesOfRequiredParameters(ICPPMethod method) {
ICPPParameter[] parameters = method.getParameters();
if (parameters.length == 0)
return Collections.emptyList();
List<IType> types = new ArrayList<IType>(parameters.length);
for (ICPPParameter parameter : parameters) {
if (!parameter.hasDefaultValue() && !parameter.isParameterPack())
types.add(parameter.getType());
}
return types;
}
/**
* For implicit methods the exception specification is inherited, search it.
*/
public static IType[] getInheritedExceptionSpecification(ICPPMethod implicitMethod, IASTNode point) {
// See 15.4.13
@ -729,9 +778,9 @@ public class ClassTypeHelper {
if (owner == null || ClassTypeHelper.getBases(owner, point).length == 0)
return null;
// we use a list as types aren't comparable, and can have duplicates (15.4.6)
int kind= getImplicitMethodKind(owner, implicitMethod);
if (kind == KIND_OTHER)
// We use a list as types aren't comparable, and can have duplicates (15.4.6)
MethodKind kind= getMethodKind(owner, implicitMethod);
if (kind == MethodKind.OTHER)
return null;
List<IType> inheritedTypeids = new ArrayList<IType>();
@ -752,265 +801,61 @@ public class ClassTypeHelper {
return inheritedTypeids.toArray(new IType[inheritedTypeids.size()]);
}
private static int getImplicitMethodKind(ICPPClassType ct, ICPPMethod method) {
if (method instanceof ICPPConstructor) {
final IFunctionType type= method.getType();
final IType[] params= type.getParameterTypes();
if (params.length == 0)
return KIND_DEFAULT_CTOR;
if (params.length == 1) {
IType t= SemanticUtil.getNestedType(params[0], SemanticUtil.TDEF);
if (SemanticUtil.isVoidType(t))
return KIND_DEFAULT_CTOR;
if (isRefToConstClass(ct, t))
return KIND_COPY_CTOR;
}
return KIND_OTHER;
/**
* If {@code type} is a, possibly qualified, reference type referring to {@code classType},
* returns that reference type. Otherwise returns {@code null}.
*/
private static ICPPReferenceType getRefToClass(ICPPClassType classType, IType type) {
while (type instanceof ITypedef) {
type= ((ITypedef) type).getType();
}
if (method.isDestructor())
return KIND_DTOR;
if (CharArrayUtils.equals(method.getNameCharArray(), OverloadableOperator.ASSIGN.toCharArray())) {
final IFunctionType type= method.getType();
final IType[] params= type.getParameterTypes();
if (params.length == 1) {
IType t= params[0];
if (isRefToConstClass(ct, t))
return KIND_ASSIGNMENT_OP;
if (type instanceof ICPPReferenceType) {
ICPPReferenceType refType = (ICPPReferenceType) type;
type= refType.getType();
while (type instanceof ITypedef) {
type= ((ITypedef) type).getType();
}
if (type instanceof IQualifierType) {
type= ((IQualifierType) type).getType();
if (classType.isSameType(type))
return refType;
}
return KIND_OTHER;
}
return KIND_OTHER;
return null;
}
private static boolean isRefToConstClass(ICPPClassType ct, IType t) {
while (t instanceof ITypedef)
t= ((ITypedef) t).getType();
if (t instanceof ICPPReferenceType) {
t= ((ICPPReferenceType) t).getType();
while (t instanceof ITypedef)
t= ((ITypedef) t).getType();
if (t instanceof IQualifierType) {
t= ((IQualifierType) t).getType();
return ct.isSameType(t);
}
}
return false;
}
private static ICPPMethod getMethodInClass(ICPPClassType ct, int kind, IASTNode point) {
private static ICPPMethod getMethodInClass(ICPPClassType ct, MethodKind kind, IASTNode point) {
switch (kind) {
case KIND_DEFAULT_CTOR:
case KIND_COPY_CTOR:
case DEFAULT_CTOR:
case COPY_CTOR:
case MOVE_CTOR:
for (ICPPConstructor ctor : getConstructors(ct, point)) {
if (!ctor.isImplicit() && getImplicitMethodKind(ct, ctor) == kind)
if (!ctor.isImplicit() && getMethodKind(ct, ctor) == kind)
return ctor;
}
return null;
case KIND_ASSIGNMENT_OP:
case COPY_ASSIGNMENT_OP:
case MOVE_ASSIGNMENT_OP:
for (ICPPMethod method : getDeclaredMethods(ct, point)) {
if (method instanceof ICPPConstructor)
continue;
if (getImplicitMethodKind(ct, method) == kind)
if (getMethodKind(ct, method) == kind)
return method;
}
return null;
case KIND_DTOR:
case DTOR:
for (ICPPMethod method : getDeclaredMethods(ct, point)) {
if (method.isDestructor())
return method;
}
return null;
case OTHER:
break;
}
return null;
}
/**
* 8.5.1 Aggregates [dcl.init.aggr]
* An aggregate is an array or a class (Clause 9) with no user-provided constructors (12.1),
* no private or protected non-static data members (Clause 11),
* no base classes (Clause 10), and no virtual functions (10.3).
*/
public static boolean isAggregateClass(ICPPClassType classTarget, IASTNode point) {
if (ClassTypeHelper.getBases(classTarget, point).length > 0)
return false;
ICPPMethod[] methods = ClassTypeHelper.getDeclaredMethods(classTarget, point);
for (ICPPMethod m : methods) {
if (m instanceof ICPPConstructor)
return false;
if (m.isVirtual()) {
return false;
}
}
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classTarget, point);
for (ICPPField field : fields) {
if (!(field.getVisibility() == ICPPMember.v_public || field.isStatic())) {
return false;
}
}
return true;
}
/**
* Returns <code>true</code> if and only if the given class has a trivial copy constructor.
* A copy constructor is trivial if:
* <ul>
* <li>it is implicitly defined by the compiler, and</li>
* <li><code>isPolymorphic(classTarget) == false</code>, and</li>
* <li>the class has no virtual base classes, and</li>
* <li>every direct base class has trivial copy constructor, and</li>
* <li>for every nonstatic data member that has class type or array of class type, that type
* has trivial copy constructor.</li>
* </ul>
* Similar to <code>std::tr1::has_trivial_copy</code>.
*
* @param classTarget the class to check
* @return <code>true</code> if the class has a trivial copy constructor
*/
public static boolean hasTrivialCopyCtor(ICPPClassType classTarget, IASTNode point) {
if (getImplicitCopyCtor(classTarget) == null)
return false;
if (isPolymorphic(classTarget))
return false;
for (ICPPBase base : classTarget.getBases()) {
if (base.isVirtual())
return false;
}
for (ICPPClassType baseClass : getAllBases(classTarget, point)) {
if (!classTarget.isSameType(baseClass) && !hasTrivialCopyCtor(baseClass, point))
return false;
}
for (ICPPField field : classTarget.getDeclaredFields()) {
if (!field.isStatic()) {
IType type = field.getType();
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE | ARRAY);
if (type instanceof ICPPClassType && !classTarget.isSameType(type) &&
!hasTrivialCopyCtor((ICPPClassType) type, point)) {
return false;
}
}
}
return true;
}
/**
* Returns the compiler-generated copy constructor for the given class, or <code>null</code>
* if the class doesn't have a compiler-generated copy constructor.
*
* @param classTarget the class to get the copy ctor for.
* @return the compiler-generated copy constructor, or <code>null</code> if the class doesn't
* have a compiler-generated copy constructor.
*/
private static ICPPConstructor getImplicitCopyCtor(ICPPClassType classTarget) {
for (ICPPConstructor ctor : classTarget.getConstructors()) {
if (ctor.isImplicit() && getImplicitMethodKind(classTarget, ctor) == KIND_COPY_CTOR)
return ctor;
}
return null;
}
/**
* Returns <code>true</code> if and only if the given class has a trivial default constructor.
* A default constructor is trivial if:
* <ul>
* <li>it is implicitly defined by the compiler, and</li>
* <li>every direct base class has trivial default constructor, and</li>
* <li>for every nonstatic data member that has class type or array of class type, that type
* has trivial default constructor.</li>
* </ul>
* Similar to <code>std::tr1::has_trivial_default_constructor</code>.
*
* @param classTarget the class to check
* @param point
* @return <code>true</code> if the class has a trivial default constructor
*/
public static boolean hasTrivialDefaultConstructor(ICPPClassType classTarget, IASTNode point) {
for (ICPPConstructor ctor : getConstructors(classTarget, point)) {
if (!ctor.isImplicit() && ctor.getParameters().length == 0)
return false;
}
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
if (!classTarget.isSameType(baseClass) && !hasTrivialDefaultConstructor(baseClass, point))
return false;
}
for (ICPPField field : getDeclaredFields(classTarget, point)) {
if (!field.isStatic()) {
IType type = field.getType();
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE | ARRAY);
if (type instanceof ICPPClassType && !classTarget.isSameType(type) &&
!hasTrivialDefaultConstructor((ICPPClassType) type, point)) {
return false;
}
}
}
return true;
}
/**
* Returns <code>true</code> if and only if the given class has a trivial destructor.
* A destructor is trivial if:
* <ul>
* <li>it is implicitly defined by the compiler, and</li>
* <li>every direct base class has trivial destructor, and</li>
* <li>for every nonstatic data member that has class type or array of class type, that type
* has trivial destructor.</li>
* </ul>
* Similar to <code>std::tr1::has_trivial_destructor</code>.
*
* @param classTarget the class to check
* @return <code>true</code> if the class has a trivial destructor
*/
public static boolean hasTrivialDestructor(ICPPClassType classTarget, IASTNode point) {
for (ICPPMethod method : getDeclaredMethods(classTarget, point)) {
if (method.isDestructor())
return false;
}
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
if (!classTarget.isSameType(baseClass) && !hasTrivialDestructor(baseClass, point))
return false;
}
for (ICPPField field : getDeclaredFields(classTarget, point)) {
if (!field.isStatic()) {
IType type = field.getType();
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE | ARRAY);
if (type instanceof ICPPClassType && !classTarget.isSameType(type) &&
!hasTrivialDestructor((ICPPClassType) type, point)) {
return false;
}
}
}
return true;
}
/**
* Returns <code>true</code> if and only if the given class declares or inherits a virtual
* function. Similar to <code>std::tr1::is_polymorphic</code>.
*
* @param classTarget the class to check
* @return <code>true</code> if the class declares or inherits a virtual function.
*/
public static boolean isPolymorphic(ICPPClassType classTarget) {
if (hasDeclaredVirtualMethod(classTarget))
return true;
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
if (hasDeclaredVirtualMethod(baseClass))
return true;
}
return false;
}
private static boolean hasDeclaredVirtualMethod(ICPPClassType classTarget) {
for (ICPPMethod method : classTarget.getDeclaredMethods()) {
if (method.isVirtual()) {
return true;
}
}
return false;
}
/**
* Checks whether class is abstract, i.e. has pure virtual functions that were
* not implemented in base after declaration.

View file

@ -23,12 +23,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
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.SizeofCalculator;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
@ -250,11 +247,4 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
}
return args;
}
protected static SizeAndAlignment getSizeAndAlignment(IType type, IASTNode point) {
SizeofCalculator calc = point == null ?
SizeofCalculator.getDefault() :
((ASTTranslationUnit) point.getTranslationUnit()).getSizeofCalculator();
return calc.sizeAndAlignment(type);
}
}

View file

@ -32,7 +32,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.VariableReadWriteFlags;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
/**
@ -61,7 +60,7 @@ public final class CPPVariableReadWriteFlags extends VariableReadWriteFlags {
IType type = CPPVisitor.createType(parent);
if (type instanceof ICPPUnknownType ||
type instanceof ICPPClassType &&
!ClassTypeHelper.hasTrivialDefaultConstructor((ICPPClassType) type, parent)) {
!TypeTraits.hasTrivialDefaultConstructor((ICPPClassType) type, parent)) {
return WRITE;
}
return super.rwInDeclarator(parent, indirection);

View file

@ -368,7 +368,7 @@ public class Conversions {
return Cost.NO_CONVERSION;
ICPPClassType classTarget= (ICPPClassType) noCVTarget;
if (ClassTypeHelper.isAggregateClass(classTarget, point)) {
if (TypeTraits.isAggregateClass(classTarget, point)) {
Cost cost= new Cost(arg.getTypeOrFunctionSet(point), target, Rank.IDENTITY);
cost.setUserDefinedConversion(null);
return cost;

View file

@ -20,14 +20,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.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.core.runtime.CoreException;
@ -83,13 +81,7 @@ public class EvalBinaryTypeId extends CPPEvaluation {
if (isValueDependent())
return Value.create(this);
switch (fOperator) {
case __is_base_of:
if (!(fType1 instanceof ICPPClassType) || !(fType1 instanceof ICPPClassType))
return Value.UNKNOWN;
return Value.create(ClassTypeHelper.isSubclass((ICPPClassType) fType2, (ICPPClassType) fType1));
}
return Value.create(this);
return Value.evaluateBinaryTypeIdExpression(fOperator, fType1, fType2, point);
}
@Override

View file

@ -49,6 +49,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArithmeticConversion;
@ -219,11 +220,11 @@ public class EvalUnary extends CPPEvaluation {
switch (fOperator) {
case op_sizeof: {
SizeAndAlignment info = getSizeAndAlignment(fArgument.getTypeOrFunctionSet(point), point);
SizeAndAlignment info = SizeofCalculator.getSizeAndAlignment(fArgument.getTypeOrFunctionSet(point), point);
return info == null ? Value.UNKNOWN : Value.create(info.size);
}
case op_alignOf: {
SizeAndAlignment info = getSizeAndAlignment(fArgument.getTypeOrFunctionSet(point), point);
SizeAndAlignment info = SizeofCalculator.getSizeAndAlignment(fArgument.getTypeOrFunctionSet(point), point);
return info == null ? Value.UNKNOWN : Value.create(info.alignment);
}
case op_noexcept:

View file

@ -37,8 +37,6 @@ import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_typeof;
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
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;
@ -46,7 +44,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
@ -163,55 +160,7 @@ public class EvalUnaryTypeID extends CPPEvaluation {
if (isValueDependent())
return Value.create(this);
switch (fOperator) {
case op_sizeof: {
SizeAndAlignment info = getSizeAndAlignment(fOrigType, point);
return info == null ? Value.UNKNOWN : Value.create(info.size);
}
case op_alignof: {
SizeAndAlignment info = getSizeAndAlignment(fOrigType, point);
return info == null ? Value.UNKNOWN : Value.create(info.alignment);
}
case op_typeid:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_has_nothrow_copy:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_has_nothrow_constructor:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_has_trivial_assign:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_has_trivial_constructor:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_has_trivial_copy:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_has_trivial_destructor:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_has_virtual_destructor:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_abstract:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_class:
return Value.create(fOrigType instanceof ICompositeType && ((ICompositeType) fOrigType).getKey() != ICompositeType.k_union);
case op_is_empty:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_enum:
return Value.create(fOrigType instanceof IEnumeration);
case op_is_literal_type:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_pod:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_polymorphic:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_standard_layout:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_trivial:
return Value.UNKNOWN; // TODO(sprigogin): Implement
case op_is_union:
return Value.create(fOrigType instanceof ICompositeType && ((ICompositeType) fOrigType).getKey() == ICompositeType.k_union);
case op_typeof:
return Value.UNKNOWN; // TODO(sprigogin): Implement
}
return Value.create(this);
return Value.evaluateUnaryTypeIdExpression(fOperator, fOrigType, point);
}
@Override

View file

@ -0,0 +1,328 @@
/*******************************************************************************
* Copyright (c) 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ARRAY;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType;
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.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
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.ICPPReferenceType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper.MethodKind;
/**
* A collection of static methods for determining type traits.
*/
public class TypeTraits {
private TypeTraits() {}
/**
* C++11: 9-6
*/
public static boolean isTrivial(ICPPClassType classType, IASTNode point) {
for (ICPPMethod method : ClassTypeHelper.getDeclaredMethods(classType, point)) {
if (method.isVirtual())
return false;
switch (ClassTypeHelper.getMethodKind(classType, method)) {
case DEFAULT_CTOR:
case COPY_CTOR:
case MOVE_CTOR:
case COPY_ASSIGNMENT_OP:
case MOVE_ASSIGNMENT_OP:
case DTOR:
return false;
default:
break;
}
}
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, point);
for (ICPPField field : fields) {
if (!field.isStatic()) {
IType fieldType = SemanticUtil.getNestedType(field.getType(), TDEF);
if (fieldType instanceof ICPPClassType && !isTrivial((ICPPClassType) fieldType, point))
return false;
}
}
for (ICPPBase base : ClassTypeHelper.getBases(classType, point)) {
if (base.isVirtual())
return false;
}
ICPPClassType[] baseClasses = ClassTypeHelper.getAllBases(classType, point);
for (ICPPClassType baseClass : baseClasses) {
if (!isTrivial(baseClass, point))
return false;
}
return true;
}
/**
* C++11: 9-7
*/
public static boolean isStandardLayout(IType type, IASTNode point) {
type = SemanticUtil.getNestedType(type, ARRAY | CVTYPE | TDEF);
if (type instanceof ICPPReferenceType)
return false;
if (!(type instanceof ICPPClassType))
return true;
ICPPClassType classType = (ICPPClassType) type;
int visibility = 0;
ICPPField firstNonStaticField = null;
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, point);
for (ICPPField field : fields) {
if (!field.isStatic()) {
if (!isStandardLayout(field.getType(), point))
return false;
int vis = field.getVisibility();
if (visibility == 0) {
visibility = vis;
} else if (vis != visibility) {
return false;
}
if (firstNonStaticField == null)
firstNonStaticField = field;
}
}
if (hasDeclaredVirtualMethod(classType, point))
return false;
for (ICPPBase base : ClassTypeHelper.getBases(classType, point)) {
if (base.isVirtual())
return false;
}
ICPPClassType[] baseClasses = ClassTypeHelper.getAllBases(classType, point);
for (ICPPClassType baseClass : baseClasses) {
if (!isStandardLayout(baseClass, point))
return false;
if (firstNonStaticField != null) {
if (TypeTraits.hasNonStaticFields(baseClass, point))
return false;
if (firstNonStaticField.getType().isSameType(baseClass))
return false;
}
}
return true;
}
/**
* C++11: 9-10
*/
public static boolean isPOD(IType type, IASTNode point) {
if (!isStandardLayout(type, point))
return false;
type = SemanticUtil.getNestedType(type, ARRAY | CVTYPE | TDEF);
if (!(type instanceof ICPPClassType))
return true;
return isTrivial((ICPPClassType) type, point);
}
/**
* 8.5.1 Aggregates [dcl.init.aggr]
* An aggregate is an array or a class (Clause 9) with no user-provided constructors (12.1),
* no private or protected non-static data members (Clause 11),
* no base classes (Clause 10), and no virtual functions (10.3).
*/
public static boolean isAggregateClass(ICPPClassType classType, IASTNode point) {
if (ClassTypeHelper.getBases(classType, point).length > 0)
return false;
ICPPMethod[] methods = ClassTypeHelper.getDeclaredMethods(classType, point);
for (ICPPMethod m : methods) {
if (m instanceof ICPPConstructor)
return false;
if (m.isVirtual()) {
return false;
}
}
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, point);
for (ICPPField field : fields) {
if (!(field.getVisibility() == ICPPMember.v_public || field.isStatic())) {
return false;
}
}
return true;
}
/**
* Returns <code>true</code> if and only if the given class has a trivial copy constructor.
* A copy constructor is trivial if:
* <ul>
* <li>it is implicitly defined by the compiler, and</li>
* <li><code>isPolymorphic(classType) is false</code>, and</li>
* <li>the class has no virtual base classes, and</li>
* <li>every direct base class has trivial copy constructor, and</li>
* <li>for every nonstatic data member that has class type or array of class type, that type
* has trivial copy constructor.</li>
* </ul>
* Similar to <code>std::tr1::has_trivial_copy</code>.
*
* @param classType the class to check
* @return <code>true</code> if the class has a trivial copy constructor
*/
public static boolean hasTrivialCopyCtor(ICPPClassType classType, IASTNode point) {
if (getImplicitCopyCtor(classType, point) == null)
return false;
if (isPolymorphic(classType, point))
return false;
for (ICPPBase base : ClassTypeHelper.getBases(classType, point)) {
if (base.isVirtual())
return false;
}
for (ICPPClassType baseClass : ClassTypeHelper.getAllBases(classType, point)) {
if (!classType.isSameType(baseClass) && !hasTrivialCopyCtor(baseClass, point))
return false;
}
for (ICPPField field : classType.getDeclaredFields()) {
if (!field.isStatic()) {
IType type = field.getType();
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE | ARRAY);
if (type instanceof ICPPClassType && !classType.isSameType(type) &&
!hasTrivialCopyCtor((ICPPClassType) type, point)) {
return false;
}
}
}
return true;
}
/**
* Returns <code>true</code> if and only if the given class has a trivial default constructor.
* A default constructor is trivial if:
* <ul>
* <li>it is implicitly defined by the compiler, and</li>
* <li>every direct base class has trivial default constructor, and</li>
* <li>for every nonstatic data member that has class type or array of class type, that type
* has trivial default constructor.</li>
* </ul>
* Similar to <code>std::tr1::has_trivial_default_constructor</code>.
*
* @param classType the class to check
* @param point
* @return <code>true</code> if the class has a trivial default constructor
*/
public static boolean hasTrivialDefaultConstructor(ICPPClassType classType, IASTNode point) {
for (ICPPConstructor ctor : ClassTypeHelper.getConstructors(classType, point)) {
if (!ctor.isImplicit() && ctor.getParameters().length == 0)
return false;
}
for (ICPPClassType baseClass : ClassTypeHelper.getAllBases(classType, null)) {
if (!classType.isSameType(baseClass) && !hasTrivialDefaultConstructor(baseClass, point))
return false;
}
for (ICPPField field : ClassTypeHelper.getDeclaredFields(classType, point)) {
if (!field.isStatic()) {
IType type = field.getType();
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE | ARRAY);
if (type instanceof ICPPClassType && !classType.isSameType(type) &&
!hasTrivialDefaultConstructor((ICPPClassType) type, point)) {
return false;
}
}
}
return true;
}
/**
* Returns <code>true</code> if and only if the given class has a trivial destructor.
* A destructor is trivial if:
* <ul>
* <li>it is implicitly defined by the compiler, and</li>
* <li>every direct base class has trivial destructor, and</li>
* <li>for every nonstatic data member that has class type or array of class type, that type
* has trivial destructor.</li>
* </ul>
* Similar to <code>std::tr1::has_trivial_destructor</code>.
*
* @param classType the class to check
* @return <code>true</code> if the class has a trivial destructor
*/
public static boolean hasTrivialDestructor(ICPPClassType classType, IASTNode point) {
for (ICPPMethod method : ClassTypeHelper.getDeclaredMethods(classType, point)) {
if (method.isDestructor())
return false;
}
for (ICPPClassType baseClass : ClassTypeHelper.getAllBases(classType, null)) {
if (!classType.isSameType(baseClass) && !hasTrivialDestructor(baseClass, point))
return false;
}
for (ICPPField field : ClassTypeHelper.getDeclaredFields(classType, point)) {
if (!field.isStatic()) {
IType type = field.getType();
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE | ARRAY);
if (type instanceof ICPPClassType && !classType.isSameType(type) &&
!hasTrivialDestructor((ICPPClassType) type, point)) {
return false;
}
}
}
return true;
}
/**
* Returns <code>true</code> if and only if the given class declares or inherits a virtual
* function. Similar to <code>std::tr1::is_polymorphic</code>.
*
* @param classType the class to check
* @return <code>true</code> if the class declares or inherits a virtual function.
*/
public static boolean isPolymorphic(ICPPClassType classType, IASTNode point) {
if (hasDeclaredVirtualMethod(classType, point))
return true;
for (ICPPClassType baseClass : ClassTypeHelper.getAllBases(classType, point)) {
if (hasDeclaredVirtualMethod(baseClass, point))
return true;
}
return false;
}
private static boolean hasNonStaticFields(ICPPClassType classType, IASTNode point) {
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, point);
for (ICPPField field : fields) {
if (!field.isStatic())
return true;
}
return false;
}
public static boolean isAbstract(ICPPClassType classType, IASTNode point) {
return ClassTypeHelper.getPureVirtualMethods(classType, point).length != 0;
}
/**
* Returns the compiler-generated copy constructor for the given class, or <code>null</code>
* 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 <code>null</code> 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)) {
if (ctor.isImplicit() && ClassTypeHelper.getMethodKind(classType, ctor) == MethodKind.COPY_CTOR)
return ctor;
}
return null;
}
private static boolean hasDeclaredVirtualMethod(ICPPClassType classType, IASTNode point) {
for (ICPPMethod method : ClassTypeHelper.getDeclaredMethods(classType, point)) {
if (method.isVirtual()) {
return true;
}
}
return false;
}
}

View file

@ -47,7 +47,8 @@ public class IndexFactory {
private static final int ALL_FRAGMENT_OPTIONS = ADD_EXTENSION_FRAGMENTS_ADD_IMPORT
| ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY | ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST
| ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER | ADD_EXTENSION_FRAGMENTS_NAVIGATION
| ADD_EXTENSION_FRAGMENTS_SEARCH | ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY;
| ADD_EXTENSION_FRAGMENTS_SEARCH | ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY
| ADD_EXTENSION_FRAGMENTS_EDITOR;
private PDOMManager fPDOMManager;

View file

@ -76,7 +76,8 @@ public final class IndexProviderManager implements IElementChangedListener {
ATTRIBUTE_CALL_HIERARCHY = "call_hierarchy",
ATTRIBUTE_TYPE_HIERARCHY = "type_hierarchy",
ATTRIBUTE_INCLUDE_BROWSER = "include_browser",
ATTRIBUTE_SEARCH = "search";
ATTRIBUTE_SEARCH = "search",
ATTRIBUTE_EDITOR = "editor";
private IIndexFragmentProvider[] fragmentProviders;
@ -171,6 +172,7 @@ public final class IndexProviderManager implements IElementChangedListener {
result |= getOption(elem, ATTRIBUTE_NAVIGATION, IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION);
result |= getOption(elem, ATTRIBUTE_SEARCH, IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH);
result |= getOption(elem, ATTRIBUTE_TYPE_HIERARCHY, IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY);
result |= getOption(elem, ATTRIBUTE_EDITOR, IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
return result;
}

View file

@ -720,7 +720,9 @@ public class PDOMManager implements IWritableIndexManager, IListener {
@Override
public boolean isIndexerIdle() {
return Job.getJobManager().find(this).length == 0;
synchronized (fTaskQueue) {
return Job.getJobManager().find(this).length == 0;
}
}
void addProject(final ICProject cproject) {
@ -1097,7 +1099,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
@Override
public void done(IJobChangeEvent event) {
synchronized (idleCondition) {
if (Job.getJobManager().find(PDOMManager.this).length == 0) {
if (isIndexerIdle()) {
idleCondition[0] = true;
idleCondition.notifyAll();
}
@ -1106,7 +1108,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
};
Job.getJobManager().addJobChangeListener(listener);
try {
if (Job.getJobManager().find(this).length == 0) {
if (isIndexerIdle()) {
return true;
}
synchronized (idleCondition) {

View file

@ -258,6 +258,13 @@ The only information needed for this extension point is the fully qualified name
</documentation>
</annotation>
</attribute>
<attribute name="editor" type="boolean" use="optional">
<annotation>
<documentation>
Whether the fragment provider shall be used for C/C++ editor.
</documentation>
</annotation>
</attribute>
</complexType>
</element>

View file

@ -66,9 +66,6 @@ public class BaseUITestCase extends BaseTestCase {
super(name);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.testplugin.util.BaseTestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
@ -79,9 +76,6 @@ public class BaseUITestCase extends BaseTestCase {
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.testplugin.util.BaseTestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception {
runEventQueue(0);
@ -131,20 +125,25 @@ public class BaseUITestCase extends BaseTestCase {
if (CCorePlugin.getIndexManager().isIndexerSetupPostponed(CoreModel.getDefault().create(file.getProject())))
continue;
index.acquireReadLock();
try {
IIndexFile[] indexFiles= index.getFiles(IndexLocationFactory.getWorkspaceIFL(file));
for (IIndexFile indexFile : indexFiles) {
if (indexFile != null && indexFile.getTimestamp() >= file.getLocalTimeStamp()) {
return;
index.acquireReadLock();
try {
IIndexFile[] indexFiles= index.getFiles(IndexLocationFactory.getWorkspaceIFL(file));
for (IIndexFile indexFile : indexFiles) {
if (indexFile != null && indexFile.getTimestamp() >= file.getLocalTimeStamp()) {
return;
}
}
} finally {
index.releaseReadLock();
int time= (int) (endTime - System.currentTimeMillis());
if (time > 0) {
CCorePlugin.getIndexManager().joinIndexer(time, npm());
}
}
} finally {
index.releaseReadLock();
int time= (int) (endTime - System.currentTimeMillis());
if (time > 0) {
CCorePlugin.getIndexManager().joinIndexer(time, npm());
}
}
catch (InterruptedException e) {
// index.acquireReadLock() can be interrupted
}
}
throw new Exception("Indexer did not complete in time!");
@ -285,7 +284,7 @@ public class BaseUITestCase extends BaseTestCase {
final protected TreeItem checkTreeNode(IViewPart part, int i0, String label) {
assertNotNull(label); // we don't handle testing for a base node to not appear; can be added if/when needed
IViewReference viewRef = part.getViewSite().getPage().findViewReference(part.getViewSite().getId());
Control viewControl = ((WorkbenchPartReference)viewRef).getPane().getControl();
Control viewControl = ((WorkbenchPartReference) viewRef).getPane().getControl();
Tree tree= null;
TreeItem root= null;
@ -374,8 +373,7 @@ public class BaseUITestCase extends BaseTestCase {
if (label == null) {
assertFalse("Tree node {" + i0 + "," + i1 + "} exists but shouldn't!", nodePresent);
}
else {
} else {
fail("Tree node " + label + "{" + i0 + "," + i1 + "} does not exist!");
}
return null;

View file

@ -56,7 +56,6 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContext;
* Common base for refactoring tests.
*/
public abstract class RefactoringTestBase extends BaseTestCase {
private static final int INDEXER_TIMEOUT_SEC = 300;
protected static final NullProgressMonitor NULL_PROGRESS_MONITOR = new NullProgressMonitor();
/** Allows empty files to be created during test setup. */

View file

@ -70,7 +70,6 @@ import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
* @author dsteffle
*/
public class BaseSelectionTestsIndexer extends BaseUITestCase {
protected static final int INDEXER_TIMEOUT_SEC = 20;
protected ICProject fCProject;
static FileManager fileManager = new FileManager();
IProgressMonitor monitor = new NullProgressMonitor();

View file

@ -100,8 +100,8 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe
int hoffset= hcode.indexOf("MyInt");
int soffset = scode.indexOf("MyInt");
IASTNode decl = testF3(file, soffset+2);
IASTNode def = testF3(hfile, hoffset+2);
IASTNode decl = testF3(file, soffset + 2);
IASTNode def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName);
assertEquals("MyInt", ((IASTName) decl).toString()); //$NON-NLS-1$
@ -113,8 +113,8 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe
hoffset= hcode.indexOf("MyConst");
soffset = scode.indexOf("MyConst");
decl = testF3(file, soffset+2);
def = testF3(hfile, hoffset+2);
decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName);
assertEquals("MyConst", ((IASTName) decl).toString()); //$NON-NLS-1$
@ -126,8 +126,8 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe
hoffset= hcode.indexOf("MyFunc");
soffset = scode.indexOf("MyFunc");
decl = testF3(file, soffset+2);
def = testF3(hfile, hoffset+2);
decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName);
assertEquals("MyFunc", ((IASTName) decl).toString()); //$NON-NLS-1$
@ -139,8 +139,8 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe
hoffset= hcode.indexOf("MyStruct");
soffset = scode.indexOf("MyStruct");
decl = testF3(file, soffset+2);
def = testF3(hfile, hoffset+2);
decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName);
assertEquals("MyStruct", ((IASTName) decl).toString()); //$NON-NLS-1$
@ -151,7 +151,6 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe
assertEquals(8, ((ASTNode) def).getLength());
}
// // the header
// extern int a; // declares
// extern const int c = 1; // defines

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.ui" version="2">
<resource path="src/org/eclipse/cdt/ui/refactoring/actions/Messages.java" type="org.eclipse.cdt.ui.refactoring.actions.Messages">
<filter id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.ui.refactoring.actions.Messages"/>
<message_argument value="org.eclipse.cdt.ui_5.5.0"/>
</message_arguments>
</filter>
</resource>
</component>

View file

@ -147,7 +147,7 @@ category.refactoring.description= C/C++ Refactorings
category.refactoring.name = Refactor - C++
refactoringExtractConstant.label = Extract Constant...
refactoringExtractLocalVariable.label = Extract Local Variable...
refactoringHideMethod.label = Hide Memeber Function...
refactoringHideMethod.label = Hide Member Function...
ActionDefinition.renameElement.name= Rename - Refactoring
@ -544,7 +544,7 @@ toggleMarkOccurrences.description= Toggles mark occurrences in C/C++ editors
OccurrenceAnnotation.label= C/C++ Occurrences
WriteOccurrenceAnnotation.label= C/C++ Write Occurrences
DocCommentOwner.name = DocCommentOwner
DocCommentOwnerExtensionPoint = Doc Comment Owner
Doxygen.name = Doxygen
# Hyperlinking
@ -609,7 +609,8 @@ includeFolderDecorator.description = Decorates missing include folders with erro
templatesViewName= Templates
AllLanguageSettingEntries.name=Providers
AllLanguageSettingEntries.name=Entries
AllLanguageSettingProviders.name=Providers
AllLanguageSettingEntries.tooltip=Language Setting Entries Providers
deleteConfigsCommand.name = Reset to Default
@ -633,7 +634,7 @@ transfer.EditorBehavior.description = Preference related to how the editor proce
# Refresh Exclusion Contributors
RefreshExclusionContributor.name = Resources
extension-point.name = Refresh Exclusion Contributor
RefreshExclusionContributorExtensionPoint = Refresh Exclusion Contributor
# New New Project Wizard
newProjectWizard.name = C/C++ Project (prototype)

View file

@ -24,10 +24,10 @@
<extension-point id="HelpInfo" name="%HelpInfo" schema="schema/HelpInfo.exsd"/>
<extension-point id="quickFixProcessors" name="%quickFixProcessorExtensionPoint" schema="schema/quickFixProcessors.exsd"/>
<extension-point id="quickAssistProcessors" name="%quickAssistProcessorExtensionPoint" schema="schema/quickAssistProcessors.exsd"/>
<extension-point id="DocCommentOwner" name="%DocCommentOwner.name" schema="schema/DocCommentOwner.exsd"/>
<extension-point id="DocCommentOwner" name="%DocCommentOwnerExtensionPoint" schema="schema/DocCommentOwner.exsd"/>
<extension-point id="workingSetConfigurations" name="%workingSetConfigurationsExtensionPoint" schema="schema/workingSetConfigurations.exsd"/>
<extension-point id="LanguageSettingsProviderAssociation" name="%LanguageSettingsProviderAssociationExtensionPoint" schema="schema/LanguageSettingsProviderAssociation.exsd"/>
<extension-point id="RefreshExclusionContributor" name="%extension-point.name" schema="schema/RefreshExclusionContributor.exsd"/>
<extension-point id="RefreshExclusionContributor" name="%RefreshExclusionContributorExtensionPoint" schema="schema/RefreshExclusionContributor.exsd"/>
<extension-point id="projectTypePages" name="%projectTypePages" schema="schema/projectTypePages.exsd"/>
<extension
@ -4347,7 +4347,7 @@
<tab
class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsEntriesTab"
icon="icons/obj16/ls_entries.gif"
name="Entries"
name="%AllLanguageSettingEntries.name"
weight="010"
helpId="FIXME cdt_u_prop_pns_inc"
parent="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage"
@ -4355,7 +4355,7 @@
<tab
class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab"
icon="icons/obj16/extension_obj.gif"
name="Providers"
name="%AllLanguageSettingProviders.name"
weight="020"
helpId="FIXME cdt_u_prop_pns_inc"
parent="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage"

View file

@ -21,6 +21,7 @@ import org.eclipse.ltk.core.refactoring.RefactoringContext;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
@ -113,7 +114,8 @@ public class CRefactoringContext extends RefactoringContext {
throw new IllegalStateException("CRefactoringContext is already disposed."); //$NON-NLS-1$
if (fIndex == null) {
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
IIndex index = CCorePlugin.getIndexManager().getIndex(projects);
IIndex index = CCorePlugin.getIndexManager().getIndex(projects,
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
try {
index.acquireReadLock();
} catch (InterruptedException e) {

View file

@ -14,7 +14,7 @@ package org.eclipse.cdt.internal.ui.refactoring;
import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
final class Messages extends NLS {
public static String DeleteFileChange_0;
public static String DeleteFileChange_1;
public static String Refactoring_name;

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.internal.ui.refactoring.dialogs;
import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
final class Messages extends NLS {
public static String CTextEditChangePreviewViewer_OrgSource;
public static String CTextEditChangePreviewViewer_RefactoredSource;
public static String ExtractInputPage_ReplaceInSubclass;

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
final class Messages extends NLS {
public static String InputPage_ConstName;
public static String InputPage_EnterConstName;
public static String InputPage_NameAlreadyDefined;

View file

@ -128,10 +128,9 @@ public class ExtractFunctionRefactoring extends CRefactoring {
"org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"; //$NON-NLS-1$
static final Integer NULL_INTEGER = Integer.valueOf(0);
static final char[] ZERO= "0".toCharArray(); //$NON-NLS-1$
private NodeContainer container;
final ExtractFunctionInformation info;
private final ExtractFunctionInformation info;
final Map<String, Integer> names;
final Container<Integer> namesCounter;
@ -142,7 +141,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private FunctionExtractor extractor;
private INodeFactory nodeFactory;
DefaultCodeFormatterOptions formattingOptions;
private DefaultCodeFormatterOptions formattingOptions;
private IIndex index;
private IASTTranslationUnit ast;

View file

@ -14,7 +14,7 @@ package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
final class Messages extends NLS {
public static String ExtractFunctionRefactoring_ExtractFunction;
public static String ExtractFunctionRefactoring_NoStmtSelected;
public static String ExtractFunctionRefactoring_TooManySelected;

View file

@ -14,7 +14,7 @@ package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;
import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
final class Messages extends NLS {
public static String CreateLocalVariable;
public static String EnterVariableName;
public static String ExpressionMustBeSelected;

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
final class Messages extends NLS {
public static String GenerateGettersAndSettersInputPage_DeselectAll;
public static String GenerateGettersAndSettersInputPage_Header;
public static String GenerateGettersAndSettersInputPage_LinkDescription;

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
final class Messages extends NLS {
public static String HideMethodRefactoring_HasExternalReferences;
public static String HideMethodRefactoring_HIDE_METHOD;
public static String HideMethodRefactoring_NoNameSelected;

View file

@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
final class Messages extends NLS {
public static String ParameterNamesInputPage_Title;
public static String ParameterNamesInputPage_CompleteMissingMails;
public static String ImplementMethodInputPage_PageTitle;

View file

@ -39,6 +39,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
@ -305,7 +306,8 @@ public class CRenameProcessor extends RenameProcessor {
if (indexLockCount == 0) {
if (fIndex == null) {
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
fIndex= CCorePlugin.getIndexManager().getIndex(projects);
fIndex = CCorePlugin.getIndexManager().getIndex(projects,
IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
}
fIndex.acquireReadLock();
}

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.internal.ui.refactoring.rename;
import org.eclipse.osgi.util.NLS;
public class RenameMessages extends NLS {
class RenameMessages extends NLS {
public static String ASTManager_error_macro_name_conflict;
public static String ASTManager_subtask_analyzing;
public static String ASTManager_task_analyze;

View file

@ -14,7 +14,7 @@ package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
class Messages extends NLS {
public static String DeclaratorFinder_NestedFunction;
public static String DeclaratorFinder_NoDeclarator;
public static String DeclaratorFinder_MultipleDeclarators;

View file

@ -14,7 +14,7 @@ package org.eclipse.cdt.internal.ui.refactoring.utils;
import org.eclipse.osgi.util.NLS;
public final class Messages extends NLS {
final class Messages extends NLS {
public static String IdentifierHelper_isKeyword;
public static String IdentifierHelper_isValid;
public static String IdentifierHelper_leadingDigit;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation, QNX Software Systems, and others.
* Copyright (c) 2007, 2012 Intel Corporation, 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
@ -11,6 +11,7 @@
* Andrew Gvozdev
* QNX Software Systems - [271628] NPE in configs for project that failed to convert
* James Blackburn (Broadcom Corp.)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
@ -51,6 +52,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.osgi.util.TextProcessor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@ -774,7 +776,7 @@ implements
if (cfgDescs[i].isActive()) {
name = name + " " + Messages.AbstractPage_16; //$NON-NLS-1$
}
configSelector.add(name);
configSelector.add(TextProcessor.process(name));
}
// Ensure that the last selected config is selected by default

View file

@ -1,45 +1,33 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2012 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.ui.refactoring.actions;
import org.eclipse.osgi.util.NLS;
/**
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.refactoring.actions.messages"; //$NON-NLS-1$
class Messages extends NLS {
public static String CRefactoringActionGroup_menu;
public static String CRenameAction_label;
public static String ExtractConstantAction_label;
/**
* @since 5.1
*/
public static String ExtractLocalVariableAction_label;
public static String ExtractFunctionAction_label;
public static String HideMethodAction_label;
public static String ImplementMethodAction_label;
public static String GettersAndSetters_label;
/**
* @since 5.3
*/
public static String ToggleFunctionAction_label;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
NLS.initializeMessages(Messages.class.getName(), Messages.class);
}
// Do not instantiate
private Messages() {
}
}

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2008 Wind River Systems, Inc. and others.
# Copyright (c) 2008, 2012 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 (Wind River Systems)
# Sergey Prigogin (Google)
###############################################################################
CRefactoringActionGroup_menu=Refactor
CRenameAction_label=Rename...

View file

@ -32,7 +32,7 @@ public class LRGCCCompleteParseExtensionsTest extends GCCCompleteParseExtensions
//override the test failed case for 342683
@Override
public void testTypetraits_Bug342683() throws Exception {}
public void testTypeTraits_Bug342683() throws Exception {}
@Override

View file

@ -17,7 +17,7 @@
<properties>
<tycho-version>0.14.1</tycho-version>
<tycho-extras-version>0.14.0</tycho-extras-version>
<platform-version>3.8milestones</platform-version>
<platform-version>3.8</platform-version>
<platform-site>http://download.eclipse.org/eclipse/updates/${platform-version}</platform-site>
<orbit-version>R20110523182458</orbit-version>
<orbit-site>http://download.eclipse.org/tools/orbit/downloads/drops/${orbit-version}/repository</orbit-site>
@ -162,6 +162,7 @@
<module>codan/org.eclipse.cdt.codan.core.test</module>
<module>build/org.eclipse.cdt.managedbuilder.core.tests</module>
<module>build/org.eclipse.cdt.managedbuilder.ui.tests</module>
<module>build/org.eclipse.cdt.make.core.tests</module>
<module>dsf-gdb/org.eclipse.cdt.tests.dsf.gdb</module>
<module>build/org.eclipse.cdt.autotools.core</module>
@ -181,6 +182,7 @@
<module>testsrunner/org.eclipse.cdt.testsrunner.feature</module>
<module>testsrunner/org.eclipse.cdt.testsrunner.source.feature</module>
<module>xlc/org.eclipse.cdt.errorparsers.xlc.tests</module>
<!--
<module>lrparser/org.eclipse.cdt.core.lrparser.tests</module>
<module>upc/org.eclipse.cdt.core.parser.upc.tests</module>

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
<version>8.2.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<version>5.0.100-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.errorparsers.xlc.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>false</useUIHarness>
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
<includes>
<include>**/AllXlcErrorParserTests.*</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -110,8 +110,7 @@ public abstract class AbstractXLCBuildOutputParser implements IScannerInfoConsol
*/
@Override
public boolean processLine(String line) {
line= line.trim();
if (line.length() == 0) {
if (line.trim().length() == 0) {
return false;
}