1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 10:45:37 +02:00

Bug 380623 - [C++11] Explicit Virtual Overrides

Change-Id: I3b40e6ef659e3734194479dafa927411d405442f
This commit is contained in:
Thomas Corbat 2012-08-28 21:12:37 -07:00 committed by Sergey Prigogin
parent 2e7dbc8b55
commit 1070edb3fc
50 changed files with 968 additions and 170 deletions

View file

@ -56,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner; import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration; import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement; import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
@ -128,6 +129,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
@ -9768,4 +9771,161 @@ public class AST2CPPTests extends AST2BaseTest {
public void testFriendTemplateParameter() throws Exception { public void testFriendTemplateParameter() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// struct S {
// virtual void mFuncDecl() final;
// virtual void mFuncDef() final {}
// };
public void testFinalFunction() throws Exception {
String code = getAboveComment();
parseAndCheckBindings(code);
BindingAssertionHelper bindingHelper = new BindingAssertionHelper(code, true);
CPPMethod functionDeclarationBinding = bindingHelper.assertNonProblem("mFuncDecl()", 9);
assertFalse(functionDeclarationBinding.isOverride());
assertTrue(functionDeclarationBinding.isFinal());
IASTNode[] functionDeclarators = functionDeclarationBinding.getDeclarations();
assertEquals(1, functionDeclarators.length);
assertInstance(functionDeclarators[0], ICPPASTFunctionDeclarator.class);
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)functionDeclarators[0], false, true);
CPPMethod functionDefinitionBinding = bindingHelper.assertNonProblem("mFuncDef()", 8);
assertFalse(functionDefinitionBinding.isOverride());
assertTrue(functionDefinitionBinding.isFinal());
IASTFunctionDeclarator declarator = functionDefinitionBinding.getDefinition();
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, false, true);
}
// struct Base {
// virtual void mFuncDecl();
// virtual void mFuncDef(){}
// };
// struct S : public Base {
// void mFuncDecl() override;
// void mFuncDef() override {}
// };
public void testOverrideFunction() throws Exception {
String code = getAboveComment();
parseAndCheckBindings(code);
BindingAssertionHelper bindingHelper = new BindingAssertionHelper(code, true);
CPPMethod functionDeclarationBinding = bindingHelper.assertNonProblem("mFuncDecl() override", 9);
assertTrue(functionDeclarationBinding.isOverride());
assertFalse(functionDeclarationBinding.isFinal());
IASTDeclarator[] functionDeclarators = functionDeclarationBinding.getDeclarations();
assertEquals(1, functionDeclarators.length);
assertInstance(functionDeclarators[0], ICPPASTFunctionDeclarator.class);
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)functionDeclarators[0], true, false);
CPPMethod functionDefinitionBinding = bindingHelper.assertNonProblem("mFuncDef() override", 8);
assertTrue(functionDefinitionBinding.isOverride());
assertFalse(functionDefinitionBinding.isFinal());
IASTFunctionDeclarator declarator = functionDefinitionBinding.getDefinition();
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, false);
}
// struct Base {
// virtual void mFuncDecl();
// virtual void mFuncDef(){}
// };
// struct S : public Base {
// void mFuncDecl() final override;
// void mFuncDef() final override {}
// };
public void testOverrideFinalFunction() throws Exception {
String code = getAboveComment();
parseAndCheckBindings(code);
BindingAssertionHelper bindingHelper = new BindingAssertionHelper(code, true);
CPPMethod functionDeclarationBinding = bindingHelper.assertNonProblem("mFuncDecl() final", 9);
assertTrue(functionDeclarationBinding.isOverride());
assertTrue(functionDeclarationBinding.isFinal());
IASTDeclarator[] functionDeclarators = functionDeclarationBinding.getDeclarations();
assertEquals(1, functionDeclarators.length);
assertInstance(functionDeclarators[0], ICPPASTFunctionDeclarator.class);
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)functionDeclarators[0], true, true);
CPPMethod functionDefinitionBinding = bindingHelper.assertNonProblem("mFuncDef() final", 8);
assertTrue(functionDefinitionBinding.isOverride());
assertTrue(functionDefinitionBinding.isFinal());
IASTFunctionDeclarator declarator = functionDefinitionBinding.getDefinition();
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, true);
}
private void assertVirtualSpecifiers(ICPPASTFunctionDeclarator declarator, boolean expectOverride, boolean expectFinal) {
assertEquals(expectOverride, declarator.isOverride());
assertEquals(expectFinal, declarator.isFinal());
}
// struct Base {
// };
// struct S final : public Base {
// };
public void testFinalClass() throws Exception {
String code = getAboveComment();
parseAndCheckBindings(code);
BindingAssertionHelper bh = new BindingAssertionHelper(code, true);
CPPClassType structBase = bh.assertNonProblem("Base {", 4);
assertFalse(structBase.isFinal());
IASTNode baseDefinitionName = structBase.getDefinition();
IASTNode baseDefinition = baseDefinitionName.getParent();
assertInstance(baseDefinition, ICPPASTCompositeTypeSpecifier.class);
assertFalse(((ICPPASTCompositeTypeSpecifier)baseDefinition).isFinal());
CPPClassType structS = bh.assertNonProblem("S", 1);
assertTrue(structS.isFinal());
IASTNode sDefinitionName = structS.getDefinition();
IASTNode sDefinition = sDefinitionName.getParent();
assertInstance(sDefinition, ICPPASTCompositeTypeSpecifier.class);
assertTrue(((ICPPASTCompositeTypeSpecifier)sDefinition).isFinal());
}
// struct S{
// template<typename T>
// void foo(T t) final {
// }
// };
//
// int main() {
// S s;
// s.foo(1);
// }
public void testFinalTemplateMethod() throws Exception {
String code = getAboveComment();
parseAndCheckBindings(code);
BindingAssertionHelper bindingHelper = new BindingAssertionHelper(code, true);
ICPPMethod fooTemplate = bindingHelper.assertNonProblem("foo(T", 3);
assertFalse(fooTemplate.isOverride());
assertTrue(fooTemplate.isFinal());
}
// void foo(){
// int final, override;
// final = 4;
// override = 2;
// }
public void testFinalAndOverrideVariables() throws Exception {
parseAndCheckBindings();
}
// struct S{
// int i;
// };
// void foo(struct S final){
// final.i = 23;
// }
public void testFinalParameter() throws Exception {
parseAndCheckBindings();
}
} }

View file

@ -9,6 +9,7 @@
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* IBM Corporation * IBM Corporation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests; package org.eclipse.cdt.internal.pdom.tests;
@ -232,4 +233,14 @@ public class ClassTests extends PDOMTestBase {
assertTrue(bindings[0] instanceof ICPPClassType); assertTrue(bindings[0] instanceof ICPPClassType);
return (ICPPClassType) bindings[0]; return (ICPPClassType) bindings[0];
} }
public void testFinalClass() throws Exception {
char[][] name = {"E".toCharArray()};
IBinding[] bindings = pdom.findBindings(name, IndexFilter.ALL, npm());
assertEquals(1, bindings.length);
assertInstance(bindings[0], ICPPClassType.class);
ICPPClassType classBinding = (ICPPClassType) bindings[0];
assertTrue(classBinding.isFinal());
}
} }

View file

@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests; package org.eclipse.cdt.internal.pdom.tests;
@ -302,4 +303,31 @@ public class MethodTests extends PDOMTestBase {
assertEquals(IBasicType.t_int, Math.min(t1, t2)); assertEquals(IBasicType.t_int, Math.min(t1, t2));
assertEquals(IBasicType.t_double, Math.max(t1, t2)); assertEquals(IBasicType.t_double, Math.max(t1, t2));
} }
public void testVirtualMemberFunction() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "E::virtualMemberFunction");
assertEquals(1, bindings.length);
assertInstance(bindings[0], ICPPMethod.class);
ICPPMethod virtMemFun = (ICPPMethod) bindings[0];
assertFalse(virtMemFun.isOverride());
assertFalse(virtMemFun.isFinal());
}
public void testOverrideVirtualMemberFunction() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "F::virtualMemberFunction");
assertEquals(1, bindings.length);
assertInstance(bindings[0], ICPPMethod.class);
ICPPMethod virtMemFun = (ICPPMethod) bindings[0];
assertTrue(virtMemFun.isOverride());
assertFalse(virtMemFun.isFinal());
}
public void testOverrideFinalVirtualMemberFunction() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "G::virtualMemberFunction");
assertEquals(1, bindings.length);
assertInstance(bindings[0], ICPPMethod.class);
ICPPMethod virtMemFun = (ICPPMethod) bindings[0];
assertTrue(virtMemFun.isOverride());
assertTrue(virtMemFun.isFinal());
}
} }

View file

@ -32,3 +32,6 @@ class D {
public: public:
D(D &) {} D(D &) {}
}; };
class E final : public A {
};

View file

@ -39,6 +39,18 @@ struct B {
struct D : public A, public B {}; struct D : public A, public B {};
struct E {
virtual void virtualMemberFunction(){}
};
struct F : public E {
void virtualMemberFunction() override{}
};
struct G : public F {
void virtualMemberFunction() override final{}
};
class Class2 : public Class1 { class Class2 : public Class1 {
public: public:
void pureVirtualMethod(); void pureVirtualMethod();

View file

@ -181,3 +181,11 @@ decltype(i) j = 3;
int i; int i;
typeof i j = 3; typeof i j = 3;
//!CPPCompositeTypeSpecifier declared final
//%CPP
class Base
{
};
class TestClass final : public Base
{
};

View file

@ -117,3 +117,32 @@ int&& foo(int&& a)
char&& b; char&& b;
} }
//!ICPPASTFunctionDeclarator in member function declared final
//%CPP
struct S
{
virtual void memFun() final;
};
//!ICPPASTFunctionDeclarator in member function declared override
//%CPP
struct S
{
virtual void memFun() override;
};
//!ICPPASTFunctionDeclarator in member function declared override final
//%CPP
struct S
{
virtual void memFun() override final;
};
//!ICPPASTFunctionDeclarator in member function definition declared final
//%CPP
struct S
{
virtual void memFun() final
{
}
};

View file

@ -8,7 +8,8 @@
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ * Thomas Corbat (IFS)
******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
@ -138,4 +139,18 @@ public interface ICPPASTCompositeTypeSpecifier extends IASTCompositeTypeSpecifie
*/ */
@Override @Override
public ICPPASTCompositeTypeSpecifier copy(CopyStyle style); public ICPPASTCompositeTypeSpecifier copy(CopyStyle style);
/**
* Queries whether the type is final.
*
* @since 5.5
*/
public boolean isFinal();
/**
* Sets whether the type is final.
*
* @since 5.5
*/
public void setFinal(boolean isFinal);
} }

View file

@ -9,6 +9,7 @@
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
@ -172,4 +173,32 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
*/ */
@Override @Override
public ICPPASTFunctionDeclarator copy(CopyStyle style); public ICPPASTFunctionDeclarator copy(CopyStyle style);
/**
* Returns whether this function is declared override.
*
* @since 5.5
*/
public boolean isOverride();
/**
* Sets whether this function is declared override.
*
* @since 5.5
*/
public void setOverride(boolean isOverride);
/**
* Returns whether this function is declared final.
*
* @since 5.5
*/
public boolean isFinal();
/**
* Sets whether this function is declared final.
*
* @since 5.5
*/
public void setFinal(boolean isFinal);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,7 +7,8 @@
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ * Thomas Corbat (IFS)
******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
@ -99,4 +100,11 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding {
* Returns an array of nested classes/structures * Returns an array of nested classes/structures
*/ */
public ICPPClassType[] getNestedClasses(); public ICPPClassType[] getNestedClasses();
/**
* Returns whether this type is declared final.
*
* @since 5.5
*/
public boolean isFinal();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
@ -49,4 +50,18 @@ public interface ICPPMethod extends ICPPFunction, ICPPMember {
* @since 5.1 * @since 5.1
*/ */
public boolean isPureVirtual(); public boolean isPureVirtual();
/**
* Returns whether this method is declared override.
*
* @since 5.5
*/
public boolean isOverride();
/**
* Returns whether this method is declared final.
*
* @since 5.5
*/
public boolean isFinal();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2010 IBM Corporation and others. * Copyright (c) 2002, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* John Camelon (IBM Rational Software) - Initial API and implementation * John Camelon (IBM Rational Software) - Initial API and implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser; package org.eclipse.cdt.core.parser;
@ -167,6 +168,8 @@ public class Keywords {
public static final char[] cFALSE = "false".toCharArray(); public static final char[] cFALSE = "false".toCharArray();
public static final char[] cFLOAT = "float".toCharArray(); public static final char[] cFLOAT = "float".toCharArray();
public static final char[] cFOR = "for".toCharArray(); public static final char[] cFOR = "for".toCharArray();
/** @since 5.5 */
public static final char[] cFINAL = "final".toCharArray();
public static final char[] cFRIEND = "friend".toCharArray(); public static final char[] cFRIEND = "friend".toCharArray();
public static final char[] cGOTO = "goto".toCharArray(); public static final char[] cGOTO = "goto".toCharArray();
public static final char[] cIF = "if".toCharArray(); public static final char[] cIF = "if".toCharArray();
@ -185,6 +188,8 @@ public class Keywords {
public static final char[] cOPERATOR = "operator".toCharArray(); public static final char[] cOPERATOR = "operator".toCharArray();
public static final char[] cOR = "or".toCharArray(); public static final char[] cOR = "or".toCharArray();
public static final char[] cOR_EQ = "or_eq".toCharArray(); public static final char[] cOR_EQ = "or_eq".toCharArray();
/** @since 5.5 */
public static final char[] cOVERRIDE = "override".toCharArray();
public static final char[] cPRIVATE = "private".toCharArray(); public static final char[] cPRIVATE = "private".toCharArray();
public static final char[] cPROTECTED = "protected".toCharArray(); public static final char[] cPROTECTED = "protected".toCharArray();
public static final char[] cPUBLIC = "public".toCharArray(); public static final char[] cPUBLIC = "public".toCharArray();

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -36,6 +37,7 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] baseSpecs; private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] baseSpecs;
private int baseSpecsPos = -1; private int baseSpecsPos = -1;
private boolean fAmbiguitiesResolved; private boolean fAmbiguitiesResolved;
private boolean isFinal;
public CPPASTCompositeTypeSpecifier() { public CPPASTCompositeTypeSpecifier() {
} }
@ -65,6 +67,7 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
copy.addMemberDeclaration(member == null ? null : member.copy(style)); copy.addMemberDeclaration(member == null ? null : member.copy(style));
for (ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers()) for (ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers())
copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy(style)); copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy(style));
copy.isFinal = isFinal;
return super.copy(copy, style); return super.copy(copy, style);
} }
@ -216,4 +219,15 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
} }
} }
} }
@Override
public boolean isFinal() {
return isFinal;
}
@Override
public void setFinal(boolean value) {
assertNotFrozen();
isFinal = value;
}
} }

View file

@ -9,6 +9,7 @@
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -42,6 +43,8 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
private boolean isVolatile; private boolean isVolatile;
private boolean isConst; private boolean isConst;
private boolean isMutable; private boolean isMutable;
private boolean isOverride;
private boolean isFinal;
private ICPPFunctionScope scope; private ICPPFunctionScope scope;
@ -66,6 +69,8 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
copy.isVolatile = isVolatile; copy.isVolatile = isVolatile;
copy.isConst = isConst; copy.isConst = isConst;
copy.isMutable = isMutable; copy.isMutable = isMutable;
copy.isOverride = isOverride;
copy.isFinal = isFinal;
for (IASTParameterDeclaration param : getParameters()) { for (IASTParameterDeclaration param : getParameters()) {
copy.addParameterDeclaration(param == null ? null : param.copy(style)); copy.addParameterDeclaration(param == null ? null : param.copy(style));
@ -294,4 +299,26 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
} }
assert false; assert false;
} }
@Override
public boolean isOverride() {
return isOverride;
}
@Override
public void setOverride(boolean value) {
assertNotFrozen();
this.isOverride = value;
}
@Override
public boolean isFinal() {
return isFinal;
}
@Override
public void setFinal(boolean value) {
assertNotFrozen();
this.isFinal = value;
}
} }

View file

@ -9,6 +9,7 @@
* Andrew Niefer (IBM) - Initial API and implementation * Andrew Niefer (IBM) - Initial API and implementation
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -124,6 +125,16 @@ public class CPPClassSpecialization extends CPPSpecialization
public ICPPFunctionType getType() { public ICPPFunctionType getType() {
return new ProblemFunctionType(getID()); return new ProblemFunctionType(getID());
} }
@Override
public boolean isOverride() {
return false;
}
@Override
public boolean isFinal() {
return false;
}
} }
private ICPPClassSpecializationScope specScope; private ICPPClassSpecializationScope specScope;
@ -422,4 +433,13 @@ public class CPPClassSpecialization extends CPPSpecialization
return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2); return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2);
} }
@Override
public boolean isFinal() {
ICPPASTCompositeTypeSpecifier typeSpecifier = getCompositeTypeSpecifier();
if (typeSpecifier != null) {
return typeSpecifier.isFinal();
}
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 IBM Corporation and others. * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -244,4 +245,13 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
} }
return null; return null;
} }
@Override
public boolean isFinal() {
ICPPASTCompositeTypeSpecifier typeSpecifier = getCompositeTypeSpecifier();
if(typeSpecifier != null){
return typeSpecifier.isFinal();
}
return false;
}
} }

View file

@ -105,6 +105,10 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
public ICPPClassType[] getNestedClasses() { public ICPPClassType[] getNestedClasses() {
return ICPPClassType.EMPTY_CLASS_ARRAY; return ICPPClassType.EMPTY_CLASS_ARRAY;
} }
@Override
public boolean isFinal() {
return false;
}
} }
private IASTName definition; private IASTName definition;
@ -393,4 +397,13 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
} }
return false; return false;
} }
@Override
public boolean isFinal() {
ICPPASTCompositeTypeSpecifier typeSpecifier = getCompositeTypeSpecifier();
if (typeSpecifier != null) {
return typeSpecifier.isFinal();
}
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Wind River Systems, Inc. and others. * Copyright (c) 2010, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Markus Schorn (Wind River Systems) - initial API and implementation * Markus Schorn (Wind River Systems) - initial API and implementation
* Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion) * Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -338,6 +339,11 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
public void addDeclaration(IASTNode node) { public void addDeclaration(IASTNode node) {
} }
@Override
public boolean isFinal() {
return false;
}
private final class ClassScope implements ICPPClassScope { private final class ClassScope implements ICPPClassScope {
@Override @Override

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Andrew Niefer (IBM Corporation) - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -187,6 +188,16 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
return false; return false;
} }
@Override
public boolean isOverride() {
return false;
}
@Override
public boolean isFinal() {
return false;
}
@Override @Override
public IBinding getOwner() { public IBinding getOwner() {
return getClassOwner(); return getClassOwner();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Andrew Niefer (IBM Corporation) - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -225,6 +226,32 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
*/ */
@Override @Override
public boolean isPureVirtual() { public boolean isPureVirtual() {
ICPPASTFunctionDeclarator declarator = findFunctionDeclarator();
if(declarator != null){
return declarator.isPureVirtual();
}
return false;
}
@Override
public boolean isFinal() {
ICPPASTFunctionDeclarator declarator = findFunctionDeclarator();
if(declarator != null){
return declarator.isFinal();
}
return false;
}
@Override
public boolean isOverride() {
ICPPASTFunctionDeclarator declarator = findFunctionDeclarator();
if(declarator != null){
return declarator.isOverride();
}
return false;
}
private ICPPASTFunctionDeclarator findFunctionDeclarator(){
if (declarations != null) { if (declarations != null) {
for (IASTDeclarator dtor : declarations) { for (IASTDeclarator dtor : declarations) {
if (dtor == null) if (dtor == null)
@ -235,12 +262,12 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
if (decl.getParent() instanceof ICPPASTCompositeTypeSpecifier) { if (decl.getParent() instanceof ICPPASTCompositeTypeSpecifier) {
dtor= ASTQueries.findTypeRelevantDeclarator(dtor); dtor= ASTQueries.findTypeRelevantDeclarator(dtor);
if (dtor instanceof ICPPASTFunctionDeclarator) { if (dtor instanceof ICPPASTFunctionDeclarator) {
return ((ICPPASTFunctionDeclarator) dtor).isPureVirtual(); return (ICPPASTFunctionDeclarator) dtor;
} }
} }
} }
} }
return false; return definition;
} }
@Override @Override

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 IBM Corporation and others. * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Andrew Niefer (IBM) - Initial API and implementation * Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -76,4 +77,14 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
public boolean isImplicit() { public boolean isImplicit() {
return false; return false;
} }
@Override
public boolean isOverride() {
return ((ICPPMethod)getTemplateDefinition()).isOverride();
}
@Override
public boolean isFinal() {
return ((ICPPMethod)getTemplateDefinition()).isFinal();
}
} }

View file

@ -9,6 +9,7 @@
* Andrew Niefer (IBM) - Initial API and implementation * Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -105,6 +106,16 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization implement
return false; return false;
} }
@Override
public boolean isOverride() {
return false;
}
@Override
public boolean isFinal() {
return false;
}
@Override @Override
public IType[] getExceptionSpecification(IASTNode point) { public IType[] getExceptionSpecification(IASTNode point) {
if (isImplicit()) { if (isImplicit()) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 IBM Corporation and others. * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Andrew Niefer (IBM) - Initial API and implementation * Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -205,21 +206,51 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
@Override @Override
public boolean isPureVirtual() { public boolean isPureVirtual() {
ICPPASTFunctionDeclarator functionDeclarator = findFunctionDeclarator();
if(functionDeclarator != null){
return functionDeclarator.isPureVirtual();
}
return false;
}
@Override
public boolean isOverride() {
ICPPASTFunctionDeclarator functionDeclarator = findFunctionDeclarator();
if(functionDeclarator != null){
return functionDeclarator.isOverride();
}
return false;
}
@Override
public boolean isFinal() {
ICPPASTFunctionDeclarator functionDeclarator = findFunctionDeclarator();
if(functionDeclarator != null){
return functionDeclarator.isFinal();
}
return false;
}
private ICPPASTFunctionDeclarator findFunctionDeclarator() {
IASTName target = null;
if (declarations != null && declarations.length > 0) { if (declarations != null && declarations.length > 0) {
IASTName decl= declarations[0]; target = declarations[0];
if (decl != null) { } else {
IASTNode parent = decl.getParent(); target = definition;
}
if (target != null) {
IASTNode parent = target.getParent();
while (!(parent instanceof IASTDeclarator) && parent != null) while (!(parent instanceof IASTDeclarator) && parent != null)
parent = parent.getParent(); parent = parent.getParent();
if (parent instanceof IASTDeclarator) { if (parent instanceof IASTDeclarator) {
IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) parent); IASTDeclarator dtor = ASTQueries
.findTypeRelevantDeclarator((IASTDeclarator) parent);
if (dtor instanceof ICPPASTFunctionDeclarator) { if (dtor instanceof ICPPASTFunctionDeclarator) {
return ((ICPPASTFunctionDeclarator) dtor).isPureVirtual(); return (ICPPASTFunctionDeclarator) dtor;
} }
} }
} }
} return null;
return false;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 IBM Corporation and others. * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Andrew Niefer (IBM) - Initial API and implementation * Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -83,4 +84,13 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali
return false; return false;
} }
@Override
public boolean isOverride() {
return false;
}
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 IBM Corporation and others. * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Andrew Niefer (IBM Corporation) - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -245,4 +246,9 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
public ICPPDeferredClassInstance asDeferredInstance() { public ICPPDeferredClassInstance asDeferredInstance() {
return null; return null;
} }
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Andrew Niefer (IBM Corporation) - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -129,4 +130,9 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPUnknownCla
public String toString() { public String toString() {
return ASTTypeUtil.getType(this); return ASTTypeUtil.getType(this);
} }
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2010 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -57,4 +58,14 @@ public class CPPUnknownConstructor extends CPPUnknownFunction implements ICPPCon
public int getVisibility() { public int getVisibility() {
return v_public; return v_public;
} }
@Override
public boolean isOverride() {
return false;
}
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -18,6 +18,7 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -132,6 +133,7 @@ import org.eclipse.cdt.core.parser.IParserLogService;
import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
@ -3295,8 +3297,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* declarator ("=" initializerClause | "(" expressionList ")")? * declarator ("=" initializerClause | "(" expressionList ")")?
* *
* @return declarator that this parsing produced. * @return declarator that this parsing produced.
* @throws BacktrackException * @throws BacktrackException request a backtrack
* request a backtrack
* @throws FoundAggregateInitializer * @throws FoundAggregateInitializer
*/ */
private IASTDeclarator initDeclarator(DtorStrategy strategy, IASTDeclSpecifier declspec, DeclarationOptions option) private IASTDeclarator initDeclarator(DtorStrategy strategy, IASTDeclSpecifier declspec, DeclarationOptions option)
@ -3305,10 +3306,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (option.fAllowInitializer) { if (option.fAllowInitializer) {
final IASTDeclarator typeRelevantDtor = ASTQueries.findTypeRelevantDeclarator(dtor); final IASTDeclarator typeRelevantDtor = ASTQueries.findTypeRelevantDeclarator(dtor);
if (option != DeclarationOptions.PARAMETER && typeRelevantDtor instanceof IASTFunctionDeclarator) { if (option != DeclarationOptions.PARAMETER && typeRelevantDtor instanceof IASTFunctionDeclarator) {
// Function declarations don't have initializers // Function declarations don't have initializers.
// For member functions we need to consider pure-virtual syntax // For member functions we need to consider virtual specifiers and pure-virtual syntax.
if (option == DeclarationOptions.CPP_MEMBER && LTcatchEOF(1) == IToken.tASSIGN if (option == DeclarationOptions.CPP_MEMBER) {
&& LTcatchEOF(2) == IToken.tINTEGER) { optionalVirtSpecifierSeq((ICPPASTFunctionDeclarator) typeRelevantDtor);
int lt1 = LTcatchEOF(1);
if (lt1 == IToken.tASSIGN && LTcatchEOF(2) == IToken.tINTEGER) {
consume(); consume();
IToken t = consume(); IToken t = consume();
char[] image = t.getCharImage(); char[] image = t.getCharImage();
@ -3316,7 +3319,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
throwBacktrack(t); throwBacktrack(t);
} }
((ICPPASTFunctionDeclarator) typeRelevantDtor).setPureVirtual(true); ((ICPPASTFunctionDeclarator) typeRelevantDtor).setPureVirtual(true);
adjustEndOffset(dtor, t.getEndOffset()); // we can only adjust the offset of the outermost dtor. adjustEndOffset(dtor, t.getEndOffset()); // We can only adjust the offset of the outermost dtor.
}
} }
} else { } else {
if (LTcatchEOF(1) == IToken.tASSIGN && LTcatchEOF(2) == IToken.tLBRACE) if (LTcatchEOF(1) == IToken.tASSIGN && LTcatchEOF(2) == IToken.tLBRACE)
@ -3346,6 +3350,36 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return dtor; return dtor;
} }
/**
* virt-specifier-seq
* virt-specifier
* virt-specifier-seq virt-specifier
*
* virt-specifier:
* override
* final
* @throws EndOfFileException
* @throws BacktrackException
*/
private void optionalVirtSpecifierSeq(ICPPASTFunctionDeclarator typeRelevantDtor)
throws EndOfFileException, BacktrackException {
while (true) {
IToken token = LAcatchEOF(1);
if (token.getType() != IToken.tIDENTIFIER)
break;
char[] tokenImage = token.getCharImage();
if (Arrays.equals(Keywords.cOVERRIDE, tokenImage)) {
consume();
typeRelevantDtor.setOverride(true);
} else if (Arrays.equals(Keywords.cFINAL, tokenImage)) {
consume();
typeRelevantDtor.setFinal(true);
} else {
break;
}
}
}
/** /**
* initializer: * initializer:
* brace-or-equal-initializer * brace-or-equal-initializer
@ -4070,6 +4104,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
ICPPASTCompositeTypeSpecifier astClassSpecifier = nodeFactory.newCompositeTypeSpecifier(classKind, name); ICPPASTCompositeTypeSpecifier astClassSpecifier = nodeFactory.newCompositeTypeSpecifier(classKind, name);
// class virt specifier
if(LT(1) == IToken.tIDENTIFIER) {
classVirtSpecifier(astClassSpecifier);
}
// base clause // base clause
if (LT(1) == IToken.tCOLON) { if (LT(1) == IToken.tCOLON) {
baseClause(astClassSpecifier); baseClause(astClassSpecifier);
@ -4135,6 +4174,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
} }
} }
/**
* Parse a class virtual specifier for a class specification.
* class-virt-specifier:
* final
* @param astClassSpecifier
*/
private void classVirtSpecifier(ICPPASTCompositeTypeSpecifier astClassSpecifier) throws EndOfFileException, BacktrackException {
IToken token = LA();
char[] tokenImage = token.getCharImage();
if(token.getType() == IToken.tIDENTIFIER && Arrays.equals(Keywords.cFINAL, tokenImage)){
consume();
astClassSpecifier.setFinal(true);
}
}
/** /**
* base-specifier: * base-specifier:
* ::? nested-name-specifier? class-name * ::? nested-name-specifier? class-name

View file

@ -9,6 +9,7 @@
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@ -230,6 +231,10 @@ public class DeclSpecWriter extends NodeWriter {
compDeclSpec.getName().accept(visitor); compDeclSpec.getName().accept(visitor);
if (compDeclSpec instanceof ICPPASTCompositeTypeSpecifier) { if (compDeclSpec instanceof ICPPASTCompositeTypeSpecifier) {
ICPPASTCompositeTypeSpecifier cppComp = (ICPPASTCompositeTypeSpecifier) compDeclSpec; ICPPASTCompositeTypeSpecifier cppComp = (ICPPASTCompositeTypeSpecifier) compDeclSpec;
if (cppComp.isFinal()) {
scribe.printSpace();
scribe.print(Keywords.cFINAL);
}
ICPPASTBaseSpecifier[] baseSpecifiers = cppComp.getBaseSpecifiers(); ICPPASTBaseSpecifier[] baseSpecifiers = cppComp.getBaseSpecifiers();
if (baseSpecifiers.length > 0) { if (baseSpecifiers.length > 0) {
scribe.print(SPACE_COLON_SPACE); scribe.print(SPACE_COLON_SPACE);

View file

@ -10,6 +10,7 @@
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@ -140,6 +141,14 @@ public class DeclaratorWriter extends NodeWriter {
scribe.printSpace(); scribe.printSpace();
scribe.print(Keywords.MUTABLE); scribe.print(Keywords.MUTABLE);
} }
if (funcDec.isOverride()) {
scribe.printSpace();
scribe.print(Keywords.cOVERRIDE);
}
if (funcDec.isFinal()) {
scribe.printSpace();
scribe.print(Keywords.cFINAL);
}
if (funcDec.isPureVirtual()) { if (funcDec.isPureVirtual()) {
scribe.print(PURE_VIRTUAL); scribe.print(PURE_VIRTUAL);
} }

View file

@ -9,6 +9,7 @@
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -184,4 +185,9 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
} }
return result; return result;
} }
@Override
public boolean isFinal() {
return ((ICPPClassType) rbinding).isFinal();
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Symbian Software Systems and others. * Copyright (c) 2007, 2012 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -57,4 +58,14 @@ class CompositeCPPMethod extends CompositeCPPFunction implements ICPPMethod {
public boolean isPureVirtual() { public boolean isPureVirtual() {
return ((ICPPMethod) rbinding).isPureVirtual(); return ((ICPPMethod) rbinding).isPureVirtual();
} }
@Override
public boolean isOverride() {
return ((ICPPMethod) rbinding).isOverride();
}
@Override
public boolean isFinal() {
return ((ICPPMethod) rbinding).isFinal();
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Symbian Software Systems and others. * Copyright (c) 2007, 2012 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -56,4 +57,14 @@ public class CompositeCPPMethodInstance extends CompositeCPPFunctionInstance imp
public boolean isPureVirtual() { public boolean isPureVirtual() {
return ((ICPPMethod) rbinding).isPureVirtual(); return ((ICPPMethod) rbinding).isPureVirtual();
} }
@Override
public boolean isOverride() {
return ((ICPPMethod) rbinding).isOverride();
}
@Override
public boolean isFinal() {
return ((ICPPMethod) rbinding).isFinal();
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Symbian Software Systems and others. * Copyright (c) 2007, 2012 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -17,7 +18,6 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
public class CompositeCPPMethodSpecialization extends CompositeCPPFunctionSpecialization public class CompositeCPPMethodSpecialization extends CompositeCPPFunctionSpecialization
implements ICPPMethod { implements ICPPMethod {
public CompositeCPPMethodSpecialization(ICompositesFactory cf, ICPPMethod method) { public CompositeCPPMethodSpecialization(ICompositesFactory cf, ICPPMethod method) {
super(cf, method); super(cf, method);
} }
@ -57,4 +57,14 @@ implements ICPPMethod {
public boolean isPureVirtual() { public boolean isPureVirtual() {
return ((ICPPMethod) rbinding).isPureVirtual(); return ((ICPPMethod) rbinding).isPureVirtual();
} }
@Override
public boolean isOverride() {
return ((ICPPMethod) rbinding).isOverride();
}
@Override
public boolean isFinal() {
return ((ICPPMethod) rbinding).isFinal();
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Symbian Software Systems and others. * Copyright (c) 2007, 2012 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -47,7 +48,6 @@ public class CompositeCPPMethodTemplate extends CompositeCPPFunctionTemplate imp
return (ICPPClassType) cf.getCompositeBinding(rowner); return (ICPPClassType) cf.getCompositeBinding(rowner);
} }
@Override @Override
public int getVisibility() { public int getVisibility() {
return ((ICPPMethod) rbinding).getVisibility(); return ((ICPPMethod) rbinding).getVisibility();
@ -58,4 +58,13 @@ public class CompositeCPPMethodTemplate extends CompositeCPPFunctionTemplate imp
return ((ICPPMethod) rbinding).isPureVirtual(); return ((ICPPMethod) rbinding).isPureVirtual();
} }
@Override
public boolean isOverride() {
return ((ICPPMethod) rbinding).isOverride();
}
@Override
public boolean isFinal() {
return ((ICPPMethod) rbinding).isFinal();
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Symbian Software Systems and others. * Copyright (c) 2007, 2012 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -19,9 +20,7 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
public class CompositeCPPMethodTemplateSpecialization public class CompositeCPPMethodTemplateSpecialization
extends CompositeCPPFunctionTemplateSpecialization extends CompositeCPPFunctionTemplateSpecialization
implements ICPPMethod { implements ICPPMethod {
public CompositeCPPMethodTemplateSpecialization(ICompositesFactory cf, ICPPFunction ft) {
public CompositeCPPMethodTemplateSpecialization(ICompositesFactory cf,
ICPPFunction ft) {
super(cf, ft); super(cf, ft);
} }
@ -60,4 +59,14 @@ public class CompositeCPPMethodTemplateSpecialization
public boolean isPureVirtual() { public boolean isPureVirtual() {
return ((ICPPMethod) rbinding).isPureVirtual(); return ((ICPPMethod) rbinding).isPureVirtual();
} }
@Override
public boolean isOverride() {
return ((ICPPMethod) rbinding).isOverride();
}
@Override
public boolean isFinal() {
return ((ICPPMethod) rbinding).isFinal();
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2011 Symbian Software Systems and others. * Copyright (c) 2007, 2012 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -36,7 +37,6 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
public class CompositeCPPTemplateTemplateParameter extends CompositeCPPBinding public class CompositeCPPTemplateTemplateParameter extends CompositeCPPBinding
implements ICPPTemplateTemplateParameter, ICPPUnknownBinding, ICPPUnknownType, IIndexType { implements ICPPTemplateTemplateParameter, ICPPUnknownBinding, ICPPUnknownType, IIndexType {
private ICPPScope unknownScope; private ICPPScope unknownScope;
public CompositeCPPTemplateTemplateParameter(ICompositesFactory cf, ICPPTemplateTemplateParameter binding) { public CompositeCPPTemplateTemplateParameter(ICompositesFactory cf, ICPPTemplateTemplateParameter binding) {
@ -180,4 +180,9 @@ public class CompositeCPPTemplateTemplateParameter extends CompositeCPPBinding
public ICPPDeferredClassInstance asDeferredInstance() { public ICPPDeferredClassInstance asDeferredInstance() {
return null; return null;
} }
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2010 Google, Inc and others. * Copyright (c) 2008, 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Sergey Prigogin (Google) - initial API and implementation * Sergey Prigogin (Google) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -140,4 +141,9 @@ class CompositeCPPUnknownClassType extends CompositeCPPUnknownBinding implements
public boolean isAnonymous() { public boolean isAnonymous() {
return false; return false;
} }
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom; package org.eclipse.cdt.internal.core.pdom.dom;
@ -615,6 +616,11 @@ public class PDOMASTAdapter {
public boolean isAnonymous() { public boolean isAnonymous() {
return ((ICPPClassType) fDelegate).isAnonymous(); return ((ICPPClassType) fDelegate).isAnonymous();
} }
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 IBM Corporation. * Copyright (c) 2006, 2012 IBM Corporation.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -38,7 +39,9 @@ class PDOMCPPAnnotation {
public static final int IMPLICIT_METHOD_OFFSET = 2; public static final int IMPLICIT_METHOD_OFFSET = 2;
public static final int EXPLICIT_METHOD_OFFSET = 3; public static final int EXPLICIT_METHOD_OFFSET = 3;
public static final int PURE_VIRTUAL_OFFSET = 4; public static final int PURE_VIRTUAL_OFFSET = 4;
public static final int MAX_EXTRA_OFFSET= PURE_VIRTUAL_OFFSET; public static final int OVERRIDE_OFFSET = 5;
public static final int FINAL_OFFSET = 6;
public static final int MAX_EXTRA_OFFSET= FINAL_OFFSET;
/** /**
* Encodes storage class specifiers and other annotation, including * Encodes storage class specifiers and other annotation, including
@ -92,6 +95,8 @@ class PDOMCPPAnnotation {
modifiers |= (method.isImplicit() ? 1 : 0) << IMPLICIT_METHOD_OFFSET; modifiers |= (method.isImplicit() ? 1 : 0) << IMPLICIT_METHOD_OFFSET;
modifiers |= (method.isPureVirtual() ? 1 : 0) << PURE_VIRTUAL_OFFSET; modifiers |= (method.isPureVirtual() ? 1 : 0) << PURE_VIRTUAL_OFFSET;
modifiers |= (method.isExplicit() ? 1 : 0) << EXPLICIT_METHOD_OFFSET; modifiers |= (method.isExplicit() ? 1 : 0) << EXPLICIT_METHOD_OFFSET;
modifiers |= (method.isOverride() ? 1 : 0) << OVERRIDE_OFFSET;
modifiers |= (method.isFinal() ? 1 : 0) << FINAL_OFFSET;
} }
return modifiers; return modifiers;
} }

View file

@ -10,6 +10,7 @@
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -57,12 +58,13 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
ICPPClassSpecialization, IPDOMMemberOwner, IPDOMCPPClassType { ICPPClassSpecialization, IPDOMMemberOwner, IPDOMCPPClassType {
private static final int FIRST_BASE = PDOMCPPSpecialization.RECORD_SIZE + 0; private static final int FIRST_BASE = PDOMCPPSpecialization.RECORD_SIZE + 0;
private static final int MEMBER_LIST = PDOMCPPSpecialization.RECORD_SIZE + 4; private static final int MEMBER_LIST = PDOMCPPSpecialization.RECORD_SIZE + 4;
private static final int FINAL = PDOMCPPSpecialization.RECORD_SIZE + 8; // byte
/** /**
* The size in bytes of a PDOMCPPClassSpecialization record in the database. * The size in bytes of a PDOMCPPClassSpecialization record in the database.
*/ */
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 8; protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 9;
private volatile ICPPClassScope fScope; private volatile ICPPClassScope fScope;
private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache
@ -71,12 +73,22 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType, public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType,
PDOMBinding specialized) throws CoreException { PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPSpecialization) classType, specialized); super(linkage, parent, (ICPPSpecialization) classType, specialized);
setFinal(classType);
} }
public PDOMCPPClassSpecialization(PDOMLinkage linkage, long bindingRecord) { public PDOMCPPClassSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord); super(linkage, bindingRecord);
} }
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof ICPPClassType) {
ICPPClassType ct= (ICPPClassType) newBinding;
setFinal(ct);
super.update(linkage, newBinding);
}
}
@Override @Override
protected int getRecordSize() { protected int getRecordSize() {
return RECORD_SIZE; return RECORD_SIZE;
@ -435,4 +447,18 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
public boolean isAnonymous() { public boolean isAnonymous() {
return false; return false;
} }
@Override
public boolean isFinal() {
try {
return getDB().getByte(record + FINAL) != 0;
} catch (CoreException e){
CCorePlugin.log(e);
return false;
}
}
private void setFinal(ICPPClassType ct) throws CoreException {
getDB().putByte(record + FINAL, (byte) (ct.isFinal() ? 1 : 0));
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2011 QNX Software Systems and others. * Copyright (c) 2005, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,6 +11,7 @@
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -52,8 +53,9 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
private static final int FIRSTFRIEND = PDOMCPPBinding.RECORD_SIZE + 8; private static final int FIRSTFRIEND = PDOMCPPBinding.RECORD_SIZE + 8;
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 12; // byte private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 12; // byte
private static final int ANONYMOUS= PDOMCPPBinding.RECORD_SIZE + 13; // byte private static final int ANONYMOUS= PDOMCPPBinding.RECORD_SIZE + 13; // byte
private static final int FINAL = PDOMCPPBinding.RECORD_SIZE + 14; // byte
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 14; protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 15;
private PDOMCPPClassScope fScope; // No need for volatile, all fields of PDOMCPPClassScope are final. private PDOMCPPClassScope fScope; // No need for volatile, all fields of PDOMCPPClassScope are final.
@ -62,6 +64,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
setKind(classType); setKind(classType);
setAnonymous(classType); setAnonymous(classType);
setFinal(classType);
// linked list is initialized by storage being zero'd by malloc // linked list is initialized by storage being zero'd by malloc
} }
@ -85,6 +88,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
ICPPClassType ct= (ICPPClassType) newBinding; ICPPClassType ct= (ICPPClassType) newBinding;
setKind(ct); setKind(ct);
setAnonymous(ct); setAnonymous(ct);
setFinal(ct);
super.update(linkage, newBinding); super.update(linkage, newBinding);
} }
} }
@ -97,6 +101,10 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
getDB().putByte(record + ANONYMOUS, (byte) (ct.isAnonymous() ? 1 : 0)); getDB().putByte(record + ANONYMOUS, (byte) (ct.isAnonymous() ? 1 : 0));
} }
private void setFinal(ICPPClassType ct) throws CoreException {
getDB().putByte(record + FINAL, (byte) (ct.isFinal() ? 1 : 0));
}
@Override @Override
public boolean mayHaveChildren() { public boolean mayHaveChildren() {
return true; return true;
@ -231,6 +239,16 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
} }
} }
@Override
public boolean isFinal() {
try {
return getDB().getByte(record + FINAL) != 0;
} catch (CoreException e){
CCorePlugin.log(e);
return false;
}
}
@Override @Override
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
if (type instanceof ITypedef) { if (type instanceof ITypedef) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2011 QNX Software Systems and others. * Copyright (c) 2007, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Bryan Wilkinson (QNX) - Initial API and implementation * Bryan Wilkinson (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -211,6 +212,11 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization
return (ICPPTemplateDefinition) getSpecializedBinding(); return (ICPPTemplateDefinition) getSpecializedBinding();
} }
@Override
public boolean isFinal() {
return getClassTemplate().isFinal();
}
@Override @Override
public ICPPTemplateArgument[] getTemplateArguments() { public ICPPTemplateArgument[] getTemplateArguments() {
try { try {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2011 QNX Software Systems and others. * Copyright (c) 2006, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
* IBM Corporation * IBM Corporation
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -257,4 +258,14 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
} }
return super.getExceptionSpecification(); return super.getExceptionSpecification();
} }
@Override
public boolean isOverride() {
return getBit(getAnnotation1(), PDOMCPPAnnotation.OVERRIDE_OFFSET);
}
@Override
public boolean isFinal() {
return getBit(getAnnotation1(), PDOMCPPAnnotation.FINAL_OFFSET);
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 QNX Software Systems and others. * Copyright (c) 2007, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -21,10 +22,8 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* @author Bryan Wilkinson * @author Bryan Wilkinson
*
*/ */
class PDOMCPPMethodInstance extends PDOMCPPFunctionInstance implements ICPPMethod { class PDOMCPPMethodInstance extends PDOMCPPFunctionInstance implements ICPPMethod {
/** /**
* The size in bytes of a PDOMCPPMethodInstance record in the database. * The size in bytes of a PDOMCPPMethodInstance record in the database.
*/ */
@ -89,4 +88,14 @@ class PDOMCPPMethodInstance extends PDOMCPPFunctionInstance implements ICPPMetho
public int getVisibility() { public int getVisibility() {
return ((ICPPMethod) getTemplateDefinition()).getVisibility(); return ((ICPPMethod) getTemplateDefinition()).getVisibility();
} }
@Override
public boolean isOverride() {
return ((ICPPMethod) getTemplateDefinition()).isOverride();
}
@Override
public boolean isFinal() {
return ((ICPPMethod) getTemplateDefinition()).isFinal();
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 QNX Software Systems and others. * Copyright (c) 2007, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Bryan Wilkinson (QNX) - Initial API and implementation * Bryan Wilkinson (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -142,4 +143,14 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
} }
return super.getExceptionSpecification(); return super.getExceptionSpecification();
} }
@Override
public boolean isOverride() {
return false;
}
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 QNX Software Systems and others. * Copyright (c) 2007, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Bryan Wilkinson (QNX) - Initial API and implementation * Bryan Wilkinson (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -150,4 +151,14 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
public boolean isPureVirtual() { public boolean isPureVirtual() {
return false; return false;
} }
@Override
public boolean isOverride() {
return false;
}
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 QNX Software Systems and others. * Copyright (c) 2007, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -101,4 +102,14 @@ class PDOMCPPMethodTemplateSpecialization extends
public boolean isPureVirtual() { public boolean isPureVirtual() {
return false; return false;
} }
@Override
public boolean isOverride() {
return false;
}
@Override
public boolean isFinal() {
return false;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2011 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -339,6 +340,11 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
return false; return false;
} }
@Override
public boolean isFinal() {
return false;
}
@Override @Override
public ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param) { public ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param) {
int pos = param.getParameterPosition(); int pos = param.getParameterPosition();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2011 Google, Inc and others. * Copyright (c) 2008, 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Sergey Prigogin (Google) - initial API and implementation * Sergey Prigogin (Google) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Thomas Corbat (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -285,4 +286,9 @@ class PDOMCPPUnknownClassType extends PDOMCPPUnknownBinding
public boolean isAnonymous() { public boolean isAnonymous() {
return false; return false;
} }
@Override
public boolean isFinal() {
return false;
}
} }