mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-22 08:25:25 +02:00
Bug 327328: Push concept of restrict up to IASTPointer and IPointerType.
This commit is contained in:
parent
6174986b48
commit
67f123cf5e
37 changed files with 209 additions and 478 deletions
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
|
@ -53,9 +54,7 @@ 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.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
|
@ -291,7 +290,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
|
||||
|
||||
static protected class CNameCollector extends CASTVisitor {
|
||||
static protected class CNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
@ -322,7 +321,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
assertEquals(count, num);
|
||||
}
|
||||
|
||||
static protected class CPPNameCollector extends CPPASTVisitor {
|
||||
static protected class CPPNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
@ -402,7 +401,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
assertEquals(str, ASTTypeUtil.getParameterTypeString(fType));
|
||||
}
|
||||
|
||||
static protected class CNameResolver extends CASTVisitor {
|
||||
static protected class CNameResolver extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
@ -427,7 +426,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
public int size() { return nameList.size(); }
|
||||
}
|
||||
|
||||
static protected class CPPNameResolver extends CPPASTVisitor {
|
||||
static protected class CPPNameResolver extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
|
|
@ -121,8 +121,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||
|
@ -3412,8 +3410,8 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
|
||||
IVariable x = (IVariable) col.getName(0).resolveBinding();
|
||||
IType t = x.getType();
|
||||
assertTrue(t instanceof IGPPPointerType);
|
||||
assertTrue(((IGPPPointerType) t).isRestrict());
|
||||
assertTrue(t instanceof IPointerType);
|
||||
assertTrue(((IPointerType) t).isRestrict());
|
||||
|
||||
tu = parse("class A {}; int A::* __restrict x;", ParserLanguage.CPP, true); //$NON-NLS-1$
|
||||
col = new CPPNameCollector();
|
||||
|
@ -3421,8 +3419,8 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
|
||||
x = (IVariable) col.getName(3).resolveBinding();
|
||||
t = x.getType();
|
||||
assertTrue(t instanceof IGPPPointerToMemberType);
|
||||
assertTrue(((IGPPPointerToMemberType) t).isRestrict());
|
||||
assertTrue(t instanceof ICPPPointerToMemberType);
|
||||
assertTrue(((ICPPPointerToMemberType) t).isRestrict());
|
||||
}
|
||||
|
||||
public void testBug87705() throws Exception {
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||
|
@ -52,8 +53,6 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
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;
|
||||
|
@ -102,7 +101,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
return suite(CompleteParser2Tests.class);
|
||||
}
|
||||
|
||||
static private class CPPNameCollector extends CPPASTVisitor {
|
||||
static private class CPPNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
@ -119,7 +118,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
}
|
||||
public int size() { return nameList.size(); }
|
||||
}
|
||||
static protected class CNameCollector extends CASTVisitor {
|
||||
static protected class CNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
|
|
@ -18,12 +18,11 @@ import junit.framework.Assert;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
|
@ -73,12 +72,13 @@ public class DOMSearchUtil {
|
|||
*
|
||||
* @author dsteffle
|
||||
*/
|
||||
static public class CPPNameCollector extends CPPASTVisitor {
|
||||
static public class CPPNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
public int visit( IASTName name ){
|
||||
@Override
|
||||
public int visit( IASTName name ){
|
||||
nameList.add( name );
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
@ -95,12 +95,13 @@ public class DOMSearchUtil {
|
|||
*
|
||||
* @author dsteffle
|
||||
*/
|
||||
static public class CNameCollector extends CASTVisitor {
|
||||
static public class CNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
public int visit( IASTName name ){
|
||||
@Override
|
||||
public int visit( IASTName name ){
|
||||
nameList.add( name );
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CASTFunctionDefinition;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CFunction;
|
||||
|
@ -130,8 +130,8 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
|||
writer.write( "int * __restrict__ resPointer1;\n"); //$NON-NLS-1$
|
||||
writer.write( "int * __restrict resPointer2;\n"); //$NON-NLS-1$
|
||||
decls = parseGPP( writer.toString() ).getDeclarations();
|
||||
assertTrue( ((IGPPASTPointer)((IASTSimpleDeclaration)decls[0]).getDeclarators()[0].getPointerOperators()[0]).isRestrict() );
|
||||
assertTrue( ((IGPPASTPointer)((IASTSimpleDeclaration)decls[1]).getDeclarators()[0].getPointerOperators()[0]).isRestrict() );
|
||||
assertTrue( ((IASTPointer)((IASTSimpleDeclaration)decls[0]).getDeclarators()[0].getPointerOperators()[0]).isRestrict() );
|
||||
assertTrue( ((IASTPointer)((IASTSimpleDeclaration)decls[1]).getDeclarators()[0].getPointerOperators()[0]).isRestrict() );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||
|
@ -73,9 +72,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
|
@ -438,16 +435,8 @@ public class ASTStringUtil {
|
|||
if (pointer.isVolatile()) {
|
||||
buffer.append(' ').append(Keywords.VOLATILE);
|
||||
}
|
||||
if (pointerOperator instanceof ICASTPointer) {
|
||||
final ICASTPointer cPointer= (ICASTPointer)pointerOperator;
|
||||
if (cPointer.isRestrict()) {
|
||||
buffer.append(' ').append(Keywords.RESTRICT);
|
||||
}
|
||||
} else if (pointerOperator instanceof IGPPASTPointer) {
|
||||
final IGPPASTPointer gppPointer= (IGPPASTPointer)pointerOperator;
|
||||
if (gppPointer.isRestrict()) {
|
||||
buffer.append(' ').append(Keywords.RESTRICT);
|
||||
}
|
||||
if (pointer.isRestrict()) {
|
||||
buffer.append(' ').append(Keywords.RESTRICT);
|
||||
}
|
||||
} else if (pointerOperator instanceof ICPPASTReferenceOperator) {
|
||||
buffer.append(Keywords.cpAMPER);
|
||||
|
@ -1110,9 +1099,9 @@ public class ASTStringUtil {
|
|||
|
||||
private static String getTypeIdExpressionOperator(IASTTypeIdExpression expression) {
|
||||
switch (expression.getOperator()) {
|
||||
case IGNUASTTypeIdExpression.op_alignof:
|
||||
case IASTTypeIdExpression.op_alignof:
|
||||
return Keywords.ALIGNOF;
|
||||
case IGNUASTTypeIdExpression.op_typeof:
|
||||
case IASTTypeIdExpression.op_typeof:
|
||||
return Keywords.TYPEOF;
|
||||
case ICPPASTTypeIdExpression.op_typeid:
|
||||
return Keywords.TYPEID;
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||
|
@ -34,7 +33,6 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
|
||||
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
||||
|
@ -188,55 +186,35 @@ public class ASTSignatureUtil {
|
|||
result.append(SPACE);
|
||||
}
|
||||
if (op instanceof IASTPointer) {
|
||||
final IASTPointer ptr = (IASTPointer) op;
|
||||
result.append(Keywords.cpSTAR); // want to have this before keywords on the pointer
|
||||
needSpace = true;
|
||||
}
|
||||
|
||||
if (op instanceof IGPPASTPointer) {
|
||||
if (((IGPPASTPointer) op).isRestrict()) {
|
||||
if (ptr.isConst()) {
|
||||
if (needSpace) {
|
||||
result.append(SPACE);
|
||||
needSpace = false;
|
||||
}
|
||||
result.append(Keywords.RESTRICT);
|
||||
needSpace = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (op instanceof ICASTPointer) {
|
||||
if (((ICASTPointer) op).isRestrict()) {
|
||||
if (needSpace) {
|
||||
result.append(SPACE);
|
||||
needSpace = false;
|
||||
}
|
||||
result.append(Keywords.RESTRICT);
|
||||
needSpace = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (op instanceof IASTPointer) {
|
||||
if (((IASTPointer) op).isConst()) {
|
||||
if (needSpace) {
|
||||
result.append(SPACE);
|
||||
needSpace = false;
|
||||
}
|
||||
result.append(Keywords.CONST);
|
||||
needSpace = true;
|
||||
}
|
||||
if (((IASTPointer) op).isVolatile()) {
|
||||
if (needSpace) {
|
||||
if (ptr.isVolatile()) {
|
||||
if (needSpace) {
|
||||
result.append(SPACE);
|
||||
needSpace = false;
|
||||
}
|
||||
result.append(Keywords.VOLATILE);
|
||||
needSpace = true;
|
||||
}
|
||||
if (ptr.isRestrict()) {
|
||||
if (needSpace) {
|
||||
result.append(SPACE);
|
||||
}
|
||||
result.append(Keywords.RESTRICT);
|
||||
needSpace = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (op instanceof ICPPASTReferenceOperator) {
|
||||
if (needSpace) {
|
||||
result.append(SPACE);
|
||||
needSpace = false;
|
||||
}
|
||||
result.append(Keywords.cpAMPER);
|
||||
needSpace = true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -18,41 +18,40 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
*/
|
||||
public interface IASTPointer extends IASTPointerOperator {
|
||||
|
||||
// Qualifiers applied to the pointer type
|
||||
/**
|
||||
* Is this a const pointer?
|
||||
*
|
||||
* @return boolean
|
||||
* Returns whether the pointer is const qualified.
|
||||
*/
|
||||
public boolean isConst();
|
||||
|
||||
/**
|
||||
* Is this a volatile pointer?
|
||||
*
|
||||
* @return boolean
|
||||
* Returns whether the pointer is volatile qualified.
|
||||
*/
|
||||
public boolean isVolatile();
|
||||
|
||||
/**
|
||||
* Set this to be a const pointer (true/false).
|
||||
*
|
||||
* @param value -
|
||||
* the value
|
||||
* Returns whether the pointer is restrict qualified.
|
||||
* @since 5.3
|
||||
*/
|
||||
public boolean isRestrict();
|
||||
|
||||
/**
|
||||
* Not allowed on frozen ast.
|
||||
*/
|
||||
public void setConst(boolean value);
|
||||
|
||||
/**
|
||||
* Set this to be a volatile pointer (true/false).
|
||||
*
|
||||
* @param value -
|
||||
* the value
|
||||
* Not allowed on frozen ast.
|
||||
*/
|
||||
public void setVolatile(boolean value);
|
||||
|
||||
/**
|
||||
* Not allowed on frozen ast.
|
||||
* @since 5.3
|
||||
*/
|
||||
public void setRestrict(boolean value);
|
||||
|
||||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
public IASTPointer copy();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
|
@ -21,12 +22,20 @@ public interface IPointerType extends IType {
|
|||
public IType getType();
|
||||
|
||||
/**
|
||||
* is this a const pointer
|
||||
* Returns whether the pointer is const qualified.
|
||||
*/
|
||||
public boolean isConst();
|
||||
|
||||
/**
|
||||
* is this a volatile pointer
|
||||
* Returns whether the pointer is volatile qualified.
|
||||
*/
|
||||
public boolean isVolatile();
|
||||
|
||||
/**
|
||||
* Returns whether the pointer is qualified to be restrict.
|
||||
* For c++ this is a gnu-extension.
|
||||
* @since 5.3
|
||||
*/
|
||||
boolean isRestrict();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.c;
|
||||
|
||||
|
@ -20,23 +21,8 @@ import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
|||
*/
|
||||
public interface ICASTPointer extends IASTPointer {
|
||||
|
||||
/**
|
||||
* Is this a restrict pointer?
|
||||
*
|
||||
* @return isRestrict boolean
|
||||
*/
|
||||
boolean isRestrict();
|
||||
|
||||
/**
|
||||
* Set this pointer to be restrict pointer.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void setRestrict(boolean value);
|
||||
|
||||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
public ICASTPointer copy();
|
||||
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
|
||||
/**
|
||||
|
@ -198,11 +196,19 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
|
||||
public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
|
||||
|
||||
public IGPPASTPointer newPointerGPP();
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newPointer()}.
|
||||
*/
|
||||
@Deprecated
|
||||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer newPointerGPP();
|
||||
|
||||
public ICPPASTPointerToMember newPointerToMember(IASTName name);
|
||||
|
||||
public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name);
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newPointerToMember(IASTName)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember newPointerToMemberGPP(IASTName name);
|
||||
|
||||
public IASTProblemTypeId newProblemTypeId(IASTProblem problem);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -13,28 +13,11 @@ package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
||||
|
||||
/**
|
||||
* g++ allows for restrict pointers.
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* @deprecated Use {@link IASTPointer}, instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IGPPASTPointer extends IASTPointer {
|
||||
|
||||
/**
|
||||
* Is this pointer a restrict pointer?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isRestrict();
|
||||
|
||||
/**
|
||||
* Set restrict-keyword-encountered to true or false.
|
||||
*
|
||||
* @param value
|
||||
* boolean
|
||||
*/
|
||||
public void setRestrict(boolean value);
|
||||
|
||||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
|
|
|
@ -13,11 +13,9 @@ package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
||||
|
||||
/**
|
||||
* G++ Pointer 2 Members accept the restrict qualified as well.
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* @deprecated Use {@link ICPPASTPointerToMember}, instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IGPPASTPointerToMember extends IGPPASTPointer, ICPPASTPointerToMember {
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitFunction;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitTypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerType;
|
||||
|
||||
/**
|
||||
* This is the IBuiltinBindingsProvider used to implement the "Other" built-in GCC symbols defined:
|
||||
|
@ -323,9 +322,9 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
|||
cpp_unspecified = new CPPBasicType(Kind.eUnspecified, 0);
|
||||
cpp_char = new CPPBasicType(Kind.eChar, 0);
|
||||
cpp_char_p = new CPPPointerType(cpp_char);
|
||||
cpp_char_p_r = new GPPPointerType(cpp_char, false, false, true);
|
||||
cpp_char_p_r = new CPPPointerType(cpp_char, false, false, true);
|
||||
cpp_const_char_p = new CPPPointerType(new CPPQualifierType(cpp_char, true, false));
|
||||
cpp_const_char_p_r = new GPPPointerType(new CPPQualifierType(cpp_char, true, false), false, false, true);
|
||||
cpp_const_char_p_r = new CPPPointerType(new CPPQualifierType(cpp_char, true, false), false, false, true);
|
||||
|
||||
cpp_double = new CPPBasicType(Kind.eDouble, 0);
|
||||
cpp_double_complex = new CPPBasicType(Kind.eDouble, IBasicType.IS_COMPLEX, null);
|
||||
|
@ -350,9 +349,9 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
|||
|
||||
cpp_void = new CPPBasicType(Kind.eVoid, 0);
|
||||
cpp_void_p = new CPPPointerType(cpp_void);
|
||||
cpp_void_p_r = new GPPPointerType(cpp_void, false, false, true);
|
||||
cpp_void_p_r = new CPPPointerType(cpp_void, false, false, true);
|
||||
cpp_const_void_p = new CPPPointerType(new CPPQualifierType(cpp_void, true, false));
|
||||
cpp_const_void_p_r = new GPPPointerType(new CPPQualifierType(cpp_void, true, false), false, false, true);
|
||||
cpp_const_void_p_r = new CPPPointerType(new CPPQualifierType(cpp_void, true, false), false, false, true);
|
||||
|
||||
cpp_FILE_p_r = cpp_void_p_r; // implemented as void* restrict
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public class CPPASTPointer extends ASTNode implements IASTPointer {
|
|||
|
||||
private boolean isConst;
|
||||
private boolean isVolatile;
|
||||
private boolean isRestrict;
|
||||
|
||||
public CPPASTPointer() {
|
||||
}
|
||||
|
@ -30,6 +31,7 @@ public class CPPASTPointer extends ASTNode implements IASTPointer {
|
|||
CPPASTPointer copy = new CPPASTPointer();
|
||||
copy.isConst = isConst;
|
||||
copy.isVolatile = isVolatile;
|
||||
copy.isRestrict = isRestrict;
|
||||
copy.setOffsetAndLength(this);
|
||||
return copy;
|
||||
}
|
||||
|
@ -42,6 +44,10 @@ public class CPPASTPointer extends ASTNode implements IASTPointer {
|
|||
return isVolatile;
|
||||
}
|
||||
|
||||
public boolean isRestrict() {
|
||||
return isRestrict;
|
||||
}
|
||||
|
||||
public void setConst(boolean value) {
|
||||
assertNotFrozen();
|
||||
isConst = value;
|
||||
|
@ -52,6 +58,11 @@ public class CPPASTPointer extends ASTNode implements IASTPointer {
|
|||
isVolatile = value;
|
||||
}
|
||||
|
||||
public void setRestrict(boolean value) {
|
||||
assertNotFrozen();
|
||||
isRestrict = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitPointerOperators) {
|
||||
|
|
|
@ -31,6 +31,7 @@ public class CPPASTPointerToMember extends CPPASTPointer implements ICPPASTPoint
|
|||
CPPASTPointerToMember copy = new CPPASTPointerToMember(n == null ? null : n.copy());
|
||||
copy.setConst(isConst());
|
||||
copy.setVolatile(isVolatile());
|
||||
copy.setRestrict(isRestrict());
|
||||
copy.setOffsetAndLength(this);
|
||||
return copy;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
// void
|
||||
IType cpp_void = new CPPBasicType(Kind.eVoid, 0);
|
||||
// void *
|
||||
IType cpp_void_p = new GPPPointerType(new CPPQualifierType(new CPPBasicType(Kind.eVoid, 0), false, false), new GPPASTPointer());
|
||||
IType cpp_void_p = new CPPPointerType(new CPPQualifierType(new CPPBasicType(Kind.eVoid, 0), false, false), new CPPASTPointer());
|
||||
// size_t // assumed: unsigned long int
|
||||
IType cpp_size_t = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG & IBasicType.IS_UNSIGNED);
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
|||
if (!member.isStatic()) { // so if the member is static it will fall through
|
||||
overload= null;
|
||||
if (!inParenthesis) {
|
||||
return new CPPPointerToMemberType(member.getType(), member.getClassOwner(), false, false);
|
||||
return new CPPPointerToMemberType(member.getType(), member.getClassOwner(), false, false, false);
|
||||
} else if (member instanceof IFunction) {
|
||||
return new ProblemBinding(operand, IProblemBinding.SEMANTIC_INVALID_TYPE, operand.getRawSignature().toCharArray());
|
||||
}
|
||||
|
|
|
@ -107,8 +107,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||
|
@ -422,7 +420,8 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
return new CPPASTPointer();
|
||||
}
|
||||
|
||||
public IGPPASTPointer newPointerGPP() {
|
||||
@Deprecated
|
||||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer newPointerGPP() {
|
||||
return new GPPASTPointer();
|
||||
}
|
||||
|
||||
|
@ -430,7 +429,8 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
return new CPPASTPointerToMember(name);
|
||||
}
|
||||
|
||||
public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name) {
|
||||
@Deprecated
|
||||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember newPointerToMemberGPP(IASTName name) {
|
||||
return new GPPASTPointerToMember(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ public class CPPPointerToMemberType extends CPPPointerType implements ICPPPointe
|
|||
this.operator = operator;
|
||||
}
|
||||
|
||||
public CPPPointerToMemberType(IType type, IType thisType, boolean isConst, boolean isVolatile) {
|
||||
super(type, isConst, isVolatile);
|
||||
public CPPPointerToMemberType(IType type, IType thisType, boolean isConst, boolean isVolatile, boolean isRestrict) {
|
||||
super(type, isConst, isVolatile, isRestrict);
|
||||
this.classType = thisType;
|
||||
}
|
||||
|
||||
|
@ -99,6 +99,7 @@ public class CPPPointerToMemberType extends CPPPointerType implements ICPPPointe
|
|||
int firstByte= ITypeMarshalBuffer.POINTER_TO_MEMBER;
|
||||
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
|
||||
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
|
||||
if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3;
|
||||
buffer.putByte((byte) firstByte);
|
||||
buffer.marshalType(getType());
|
||||
buffer.marshalType(getMemberOfClass());
|
||||
|
@ -108,6 +109,7 @@ public class CPPPointerToMemberType extends CPPPointerType implements ICPPPointe
|
|||
IType nested= buffer.unmarshalType();
|
||||
IType memberOf= buffer.unmarshalType();
|
||||
return new CPPPointerToMemberType(nested, memberOf, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
|
||||
(firstByte & ITypeMarshalBuffer.FLAG2) != 0);
|
||||
(firstByte & ITypeMarshalBuffer.FLAG2) != 0,
|
||||
(firstByte & ITypeMarshalBuffer.FLAG3) != 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,34 +26,26 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* Pointers in c++
|
||||
*/
|
||||
public class CPPPointerType implements IPointerType, ITypeContainer, ISerializableType {
|
||||
protected IType type = null;
|
||||
private boolean isConst = false;
|
||||
private boolean isVolatile = false;
|
||||
protected IType type;
|
||||
private boolean isConst;
|
||||
private boolean isVolatile;
|
||||
private boolean isRestrict;
|
||||
|
||||
public CPPPointerType(IType type, boolean isConst, boolean isVolatile) {
|
||||
public CPPPointerType(IType type, boolean isConst, boolean isVolatile, boolean isRestrict) {
|
||||
this.isConst = isConst;
|
||||
this.isVolatile = isVolatile;
|
||||
this.isRestrict = isRestrict;
|
||||
setType(type);
|
||||
}
|
||||
|
||||
public CPPPointerType(IType type, IASTPointer operator) {
|
||||
this(type, operator.isConst(), operator.isVolatile());
|
||||
this(type, operator.isConst(), operator.isVolatile(), operator.isRestrict());
|
||||
}
|
||||
|
||||
public CPPPointerType(IType type) {
|
||||
this(type, false, false);
|
||||
this(type, false, false, false);
|
||||
}
|
||||
|
||||
public IType stripQualifiers() {
|
||||
CPPPointerType result = this;
|
||||
if (isConst || isVolatile) {
|
||||
result = (CPPPointerType) clone();
|
||||
result.isConst = false;
|
||||
result.isVolatile = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isSameType(IType o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
|
@ -70,7 +62,7 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
|
|||
return false;
|
||||
|
||||
IPointerType pt = (IPointerType) o;
|
||||
if (isConst == pt.isConst() && isVolatile == pt.isVolatile()) {
|
||||
if (isConst == pt.isConst() && isVolatile == pt.isVolatile() && isRestrict == pt.isRestrict()) {
|
||||
return type.isSameType(pt.getType());
|
||||
}
|
||||
return false;
|
||||
|
@ -92,7 +84,11 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
|
|||
public boolean isVolatile() {
|
||||
return isVolatile;
|
||||
}
|
||||
|
||||
|
||||
public boolean isRestrict() {
|
||||
return isRestrict;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
IType t = null;
|
||||
|
@ -113,6 +109,7 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
|
|||
int firstByte= ITypeMarshalBuffer.POINTER;
|
||||
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
|
||||
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
|
||||
if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3;
|
||||
buffer.putByte((byte) firstByte);
|
||||
final IType nestedType = getType();
|
||||
buffer.marshalType(nestedType);
|
||||
|
@ -121,6 +118,7 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
|
|||
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
|
||||
IType nested= buffer.unmarshalType();
|
||||
return new CPPPointerType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
|
||||
(firstByte & ITypeMarshalBuffer.FLAG2) != 0);
|
||||
(firstByte & ITypeMarshalBuffer.FLAG2) != 0,
|
||||
(firstByte & ITypeMarshalBuffer.FLAG3) != 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,8 +115,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
|
@ -3393,24 +3391,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
IASTPointer pointer;
|
||||
if (name != null) {
|
||||
if (isRestrict) {
|
||||
IGPPASTPointerToMember gppp2m = nodeFactory.newPointerToMemberGPP(name);
|
||||
gppp2m.setRestrict(true);
|
||||
pointer= gppp2m;
|
||||
} else {
|
||||
pointer= nodeFactory.newPointerToMember(name);
|
||||
}
|
||||
pointer= nodeFactory.newPointerToMember(name);
|
||||
} else {
|
||||
if (isRestrict) {
|
||||
IGPPASTPointer gpppo = nodeFactory.newPointerGPP();
|
||||
gpppo.setRestrict(true);
|
||||
pointer= gpppo;
|
||||
} else {
|
||||
pointer = nodeFactory.newPointer();
|
||||
}
|
||||
pointer = nodeFactory.newPointer();
|
||||
}
|
||||
pointer.setConst(isConst);
|
||||
pointer.setVolatile(isVolatile);
|
||||
pointer.setRestrict(isRestrict);
|
||||
setRange(pointer, startOffset, endOffset);
|
||||
if (result == null) {
|
||||
result= new ArrayList<IASTPointerOperator>(4);
|
||||
|
|
|
@ -13,28 +13,18 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public class GPPASTPointer extends CPPASTPointer implements IGPPASTPointer {
|
||||
|
||||
private boolean isRestrict;
|
||||
|
||||
@Override
|
||||
public GPPASTPointer copy() {
|
||||
GPPASTPointer copy = new GPPASTPointer();
|
||||
copy.setConst(isConst());
|
||||
copy.setVolatile(isVolatile());
|
||||
copy.setRestrict(isRestrict);
|
||||
copy.setRestrict(isRestrict());
|
||||
copy.setOffsetAndLength(this);
|
||||
return copy;
|
||||
}
|
||||
|
||||
public boolean isRestrict() {
|
||||
return isRestrict;
|
||||
}
|
||||
|
||||
public void setRestrict(boolean value) {
|
||||
isRestrict = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,9 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public class GPPASTPointerToMember extends CPPASTPointerToMember implements
|
||||
IGPPASTPointerToMember {
|
||||
|
||||
|
@ -27,31 +28,14 @@ public class GPPASTPointerToMember extends CPPASTPointerToMember implements
|
|||
super(n);
|
||||
}
|
||||
|
||||
private boolean isRestrict;
|
||||
|
||||
@Override
|
||||
public GPPASTPointerToMember copy() {
|
||||
IASTName name = getName();
|
||||
GPPASTPointerToMember copy = new GPPASTPointerToMember(name == null ? null : name.copy());
|
||||
copy.setConst(isConst());
|
||||
copy.setVolatile(isVolatile());
|
||||
copy.setRestrict(isRestrict);
|
||||
copy.setRestrict(isRestrict());
|
||||
copy.setOffsetAndLength(this);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer#isRestrict()
|
||||
*/
|
||||
public boolean isRestrict() {
|
||||
return isRestrict;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer#setRestrict(boolean)
|
||||
*/
|
||||
public void setRestrict(boolean value) {
|
||||
isRestrict = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerToMemberType;
|
||||
|
||||
public class GPPPointerToMemberType extends CPPPointerToMemberType implements IGPPPointerToMemberType {
|
||||
private boolean isRestrict;
|
||||
|
||||
public GPPPointerToMemberType(IType type, IGPPASTPointerToMember operator) {
|
||||
super(type, operator);
|
||||
this.isRestrict = operator.isRestrict();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType stripQualifiers() {
|
||||
GPPPointerToMemberType result = (GPPPointerToMemberType) super.stripQualifiers();
|
||||
|
||||
if (isRestrict) {
|
||||
if (result == this) {
|
||||
result = (GPPPointerToMemberType) clone();
|
||||
result.isRestrict = false;
|
||||
} else {
|
||||
result.isRestrict = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType#isRestrict()
|
||||
*/
|
||||
public boolean isRestrict() {
|
||||
return isRestrict;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof ITypedef) {
|
||||
return o.isSameType(this);
|
||||
}
|
||||
|
||||
if (!super.isSameType(o))
|
||||
return false;
|
||||
if (o instanceof IGPPPointerToMemberType) {
|
||||
return (isRestrict == ((IGPPPointerToMemberType) o).isRestrict());
|
||||
}
|
||||
return (isRestrict == false);
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType;
|
||||
|
||||
public class GPPPointerType extends CPPPointerType implements IGPPPointerType {
|
||||
private boolean isRestrict = false;
|
||||
|
||||
public GPPPointerType( IType type, IGPPASTPointer operator ) {
|
||||
super( type, operator );
|
||||
isRestrict = operator.isRestrict();
|
||||
}
|
||||
|
||||
public GPPPointerType( IType type ){
|
||||
super( type );
|
||||
}
|
||||
|
||||
public GPPPointerType( IType type, boolean isConst, boolean isVolatile, boolean isRestrict ) {
|
||||
super( type, isConst, isVolatile );
|
||||
this.isRestrict = isRestrict;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType stripQualifiers(){
|
||||
GPPPointerType result = (GPPPointerType) super.stripQualifiers();
|
||||
|
||||
if( isRestrict ){
|
||||
if( result == this ){
|
||||
result = (GPPPointerType) clone();
|
||||
result.isRestrict = false;
|
||||
} else {
|
||||
result.isRestrict = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer#isRestrict()
|
||||
*/
|
||||
public boolean isRestrict() {
|
||||
return isRestrict;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof ITypedef) {
|
||||
return o.isSameType(this);
|
||||
}
|
||||
|
||||
if (!super.isSameType(o))
|
||||
return false;
|
||||
|
||||
if (o instanceof IGPPPointerType) {
|
||||
return (isRestrict == ((IGPPPointerType) o).isRestrict());
|
||||
}
|
||||
return (isRestrict == false);
|
||||
}
|
||||
}
|
|
@ -1115,7 +1115,7 @@ public class CPPTemplates {
|
|||
}
|
||||
if (newNestedType != nestedType || newMemberOfClass != memberOfClass) {
|
||||
return new CPPPointerToMemberType(newNestedType, newMemberOfClass,
|
||||
ptm.isConst(), ptm.isVolatile());
|
||||
ptm.isConst(), ptm.isVolatile(), ptm.isRestrict());
|
||||
}
|
||||
return typeContainer;
|
||||
}
|
||||
|
|
|
@ -143,8 +143,6 @@ 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.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
@ -182,8 +180,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerToMemberType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
|
@ -1683,12 +1679,8 @@ public class CPPVisitor extends ASTQueries {
|
|||
private static IType getPointerTypes(IType type, IASTDeclarator declarator) {
|
||||
IASTPointerOperator[] ptrOps = declarator.getPointerOperators();
|
||||
for (IASTPointerOperator ptrOp : ptrOps) {
|
||||
if (ptrOp instanceof IGPPASTPointerToMember) {
|
||||
type = new GPPPointerToMemberType(type, (IGPPASTPointerToMember) ptrOp);
|
||||
} else if (ptrOp instanceof ICPPASTPointerToMember) {
|
||||
if (ptrOp instanceof ICPPASTPointerToMember) {
|
||||
type = new CPPPointerToMemberType(type, (ICPPASTPointerToMember) ptrOp);
|
||||
} else if (ptrOp instanceof IGPPASTPointer) {
|
||||
type = new GPPPointerType(type, (IGPPASTPointer) ptrOp);
|
||||
} else if (ptrOp instanceof IASTPointer) {
|
||||
type = new CPPPointerType(type, (IASTPointer) ptrOp);
|
||||
} else if (ptrOp instanceof ICPPASTReferenceOperator) {
|
||||
|
|
|
@ -869,7 +869,7 @@ public class Conversions {
|
|||
if (val instanceof IASTLiteralExpression) {
|
||||
IASTLiteralExpression lit= (IASTLiteralExpression) val;
|
||||
if (lit.getKind() == IASTLiteralExpression.lk_string_literal) {
|
||||
source= new CPPPointerType(srcTarget, false, false);
|
||||
source= new CPPPointerType(srcTarget, false, false, false);
|
||||
cost.setQualificationAdjustment((getCVQualifier(targetPtrTgt).isVolatile() ? 2 : 1) << 2);
|
||||
}
|
||||
}
|
||||
|
@ -1137,7 +1137,7 @@ public class Conversions {
|
|||
cost.setRank(Rank.CONVERSION);
|
||||
cost.setInheritanceDistance(depth);
|
||||
cost.source = new CPPPointerToMemberType(spm.getType(),
|
||||
tpm.getMemberOfClass(), spm.isConst(), spm.isVolatile());
|
||||
tpm.getMemberOfClass(), spm.isConst(), spm.isVolatile(), spm.isRestrict());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1276,9 +1276,9 @@ public class Conversions {
|
|||
final boolean isVolatile) {
|
||||
if (p1 instanceof ICPPPointerToMemberType) {
|
||||
ICPPPointerToMemberType ptm= (ICPPPointerToMemberType) p1;
|
||||
return new CPPPointerToMemberType(target, ptm.getMemberOfClass(), isConst, isVolatile);
|
||||
return new CPPPointerToMemberType(target, ptm.getMemberOfClass(), isConst, isVolatile, false);
|
||||
}
|
||||
return new CPPPointerType(target, isConst, isVolatile);
|
||||
return new CPPPointerType(target, isConst, isVolatile, false);
|
||||
}
|
||||
|
||||
private static boolean isNullPtr(IType t1) {
|
||||
|
|
|
@ -241,18 +241,16 @@ public class SemanticUtil {
|
|||
if ((ptr && !isMbrPtr) || (mptr && isMbrPtr)) {
|
||||
t= ((IPointerType) type).getType();
|
||||
} else if (allcvq) {
|
||||
if (type instanceof CPPPointerType) {
|
||||
return ((CPPPointerType) type).stripQualifiers();
|
||||
}
|
||||
IPointerType p= (IPointerType) type;
|
||||
if (p.isConst() || p.isVolatile()) {
|
||||
if (p instanceof ICPPPointerToMemberType) {
|
||||
final IType memberOfClass = ((ICPPPointerToMemberType) p).getMemberOfClass();
|
||||
return new CPPPointerToMemberType(p.getType(), memberOfClass, false, false);
|
||||
IPointerType pt= (IPointerType) type;
|
||||
if (pt.isConst() || pt.isVolatile() || pt.isRestrict()) {
|
||||
if (pt instanceof ICPPPointerToMemberType) {
|
||||
final IType memberOfClass = ((ICPPPointerToMemberType) pt).getMemberOfClass();
|
||||
return new CPPPointerToMemberType(pt.getType(), memberOfClass, false, false, false);
|
||||
} else {
|
||||
return new CPPPointerType(p.getType(), false, false);
|
||||
return new CPPPointerType(pt.getType(), false, false, false);
|
||||
}
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
} else if (tdef && type instanceof ITypedef) {
|
||||
t= ((ITypedef) type).getType();
|
||||
|
@ -469,13 +467,13 @@ public class SemanticUtil {
|
|||
ICPPPointerToMemberType pt= (ICPPPointerToMemberType) baseType;
|
||||
if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) {
|
||||
return new CPPPointerToMemberType(pt.getType(), pt.getMemberOfClass(), cnst
|
||||
|| pt.isConst(), vol || pt.isVolatile());
|
||||
|| pt.isConst(), vol || pt.isVolatile(), pt.isRestrict());
|
||||
}
|
||||
return baseType;
|
||||
} else if (baseType instanceof IPointerType) {
|
||||
IPointerType pt= (IPointerType) baseType;
|
||||
if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) {
|
||||
return new CPPPointerType(pt.getType(), cnst || pt.isConst(), vol || pt.isVolatile());
|
||||
return new CPPPointerType(pt.getType(), cnst || pt.isConst(), vol || pt.isVolatile(), pt.isRestrict());
|
||||
}
|
||||
return baseType;
|
||||
} else if (baseType instanceof IArrayType) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
|
@ -25,13 +26,10 @@ import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||
|
||||
|
||||
|
@ -52,7 +50,7 @@ public class DeclaratorWriter extends NodeWriter {
|
|||
private static final String STAR_SPACE = "* "; //$NON-NLS-1$
|
||||
private static final String PURE_VIRTUAL = " =0"; //$NON-NLS-1$
|
||||
|
||||
public DeclaratorWriter(Scribe scribe, CPPASTVisitor visitor, NodeCommentMap commentMap) {
|
||||
public DeclaratorWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
|
||||
super(scribe, visitor, commentMap);
|
||||
}
|
||||
|
||||
|
@ -176,22 +174,12 @@ public class DeclaratorWriter extends NodeWriter {
|
|||
|
||||
if (operator.isConst()) {
|
||||
scribe.printStringSpace(CONST);
|
||||
|
||||
}
|
||||
if (operator.isVolatile()) {
|
||||
scribe.printStringSpace(VOLATILE);
|
||||
}
|
||||
if (operator instanceof ICASTPointer) {
|
||||
ICASTPointer cPoint = (ICASTPointer) operator;
|
||||
if(cPoint.isRestrict()) {
|
||||
scribe.print(RESTRICT);
|
||||
}
|
||||
}
|
||||
if (operator instanceof IGPPASTPointer) {
|
||||
IGPPASTPointer gppPoint = (IGPPASTPointer) operator;
|
||||
if(gppPoint.isRestrict()) {
|
||||
scribe.print(RESTRICT);
|
||||
}
|
||||
if (operator.isRestrict()) {
|
||||
scribe.print(RESTRICT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
|||
public class NodeWriter {
|
||||
|
||||
protected Scribe scribe;
|
||||
protected CPPASTVisitor visitor;
|
||||
protected ASTVisitor visitor;
|
||||
protected NodeCommentMap commentMap;
|
||||
protected static final String COMMA_SPACE = ", "; //$NON-NLS-1$
|
||||
protected static final String EQUALS = " = "; //$NON-NLS-1$
|
||||
|
@ -59,7 +59,7 @@ public class NodeWriter {
|
|||
protected static final String VAR_ARGS = "..."; //$NON-NLS-1$
|
||||
protected static final String COLON_COLON = "::"; //$NON-NLS-1$
|
||||
|
||||
public NodeWriter(Scribe scribe, CPPASTVisitor visitor, NodeCommentMap commentMap) {
|
||||
public NodeWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
|
||||
super();
|
||||
this.scribe = scribe;
|
||||
this.visitor = visitor;
|
||||
|
|
|
@ -146,7 +146,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
IType t= pmt.getType();
|
||||
IType t2= getCompositeType(t);
|
||||
if (ct != ct2 || t != t2) {
|
||||
return new CPPPointerToMemberType(t2, ct2, pmt.isConst(), pmt.isVolatile());
|
||||
return new CPPPointerToMemberType(t2, ct2, pmt.isConst(), pmt.isVolatile(), pmt.isRestrict());
|
||||
}
|
||||
return pmt;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
IType r= pt.getType();
|
||||
IType r2= getCompositeType(r);
|
||||
if (r != r2) {
|
||||
return new CPPPointerType(r2, pt.isConst(), pt.isVolatile());
|
||||
return new CPPPointerType(r2, pt.isConst(), pt.isVolatile(), pt.isRestrict());
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@ package org.eclipse.cdt.ui.tests.DOMAST;
|
|||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
@ -31,8 +33,6 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemHolder;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
|
@ -41,7 +41,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMASTAction {
|
||||
public class CPopulateASTViewAction extends ASTVisitor implements IPopulateDOMASTAction {
|
||||
private static final int INITIAL_PROBLEM_SIZE = 4;
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
|
@ -149,13 +149,13 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
|
|||
DOMASTNodeLeaf temp = addRoot(declarator);
|
||||
|
||||
IASTPointerOperator[] ops = declarator.getPointerOperators();
|
||||
for(int i=0; i<ops.length; i++)
|
||||
addRoot(ops[i]);
|
||||
for (IASTPointerOperator op : ops)
|
||||
addRoot(op);
|
||||
|
||||
if (declarator instanceof IASTArrayDeclarator) {
|
||||
IASTArrayModifier[] mods = ((IASTArrayDeclarator)declarator).getArrayModifiers();
|
||||
for(int i=0; i<mods.length; i++)
|
||||
addRoot(mods[i]);
|
||||
for (IASTArrayModifier mod : mods)
|
||||
addRoot(mod);
|
||||
}
|
||||
|
||||
if (temp == null)
|
||||
|
@ -310,11 +310,11 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
|
|||
}
|
||||
|
||||
public void mergePreprocessorProblems(IASTProblem[] problems) {
|
||||
for(int i=0; i<problems.length; i++) {
|
||||
for (IASTProblem problem : problems) {
|
||||
if (monitor != null && monitor.isCanceled()) return;
|
||||
|
||||
if (problems[i] instanceof ASTNode)
|
||||
mergeNode((ASTNode)problems[i]);
|
||||
if (problem instanceof ASTNode)
|
||||
mergeNode((ASTNode)problem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,10 +331,8 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
|
|||
|
||||
final String path= ((IASTPreprocessorIncludeStatement) nodeLeaf.getNode()).getPath();
|
||||
final DOMASTNodeLeaf[] children = root.getChildren(false);
|
||||
for(int j=0; j < children.length; j++) {
|
||||
// if (monitor != null && monitor.isCanceled()) return; // this causes a deadlock when checked here
|
||||
final DOMASTNodeLeaf child = children[j];
|
||||
if (child != null && child != nodeLeaf &&
|
||||
for (final DOMASTNodeLeaf child : children) {
|
||||
if (child != null && child != nodeLeaf &&
|
||||
child.getNode().getContainingFilename().equals(path)) {
|
||||
root.removeChild(child);
|
||||
((DOMASTNodeParent)nodeLeaf).addChild(child);
|
||||
|
|
|
@ -54,9 +54,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
|
@ -258,20 +256,6 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
} else if ( node instanceof IASTPointer ) {
|
||||
boolean started = false;
|
||||
|
||||
if (node instanceof ICASTPointer) {
|
||||
if (((ICASTPointer)node).isRestrict()) {
|
||||
started = true;
|
||||
buffer.append(START_OF_LIST);
|
||||
buffer.append(RESTRICT_);
|
||||
}
|
||||
} else if (node instanceof IGPPASTPointer) {
|
||||
if (((IGPPASTPointer)node).isRestrict()) {
|
||||
started = true;
|
||||
buffer.append(START_OF_LIST);
|
||||
buffer.append(RESTRICT_);
|
||||
}
|
||||
}
|
||||
|
||||
if (((IASTPointer)node).isConst()) {
|
||||
if (!started) {
|
||||
started = true;
|
||||
|
@ -287,6 +271,15 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
}
|
||||
buffer.append(VOLATILE_);
|
||||
}
|
||||
|
||||
if (((IASTPointer)node).isRestrict()) {
|
||||
if (!started) {
|
||||
started = true;
|
||||
buffer.append(START_OF_LIST);
|
||||
}
|
||||
buffer.append(RESTRICT_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
|
|
|
@ -22,12 +22,11 @@ import org.eclipse.jface.viewers.TreeViewer;
|
|||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CASTTranslationUnit;
|
||||
|
@ -45,13 +44,13 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
boolean wasForward = true;
|
||||
int index = 0;
|
||||
|
||||
static protected class CNameCollector extends CASTVisitor {
|
||||
static protected class CNameCollector extends ASTVisitor {
|
||||
private static final int REGULAR_NAME_ADD = -1;
|
||||
private static final String BLANK_STRING = ""; //$NON-NLS-1$
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
public List<IASTName> nameList = new ArrayList<IASTName>();
|
||||
|
||||
String findString = null;
|
||||
boolean caseSensitive = true;
|
||||
|
@ -100,13 +99,14 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public int visit( IASTName name ){
|
||||
@Override
|
||||
public int visit( IASTName name ){
|
||||
return processName(name, REGULAR_NAME_ADD);
|
||||
}
|
||||
public IASTName getName( int idx ){
|
||||
if( idx < 0 || idx >= nameList.size() )
|
||||
return null;
|
||||
return (IASTName) nameList.get( idx );
|
||||
return nameList.get( idx );
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
|
||||
|
@ -127,9 +127,9 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
|
||||
public IASTName[] getNameArray(IASTPreprocessorStatement[] statements) {
|
||||
// first merge all of the preprocessor names into the array list
|
||||
for(int i=0; i<statements.length; i++) {
|
||||
if (statements[i] instanceof IASTPreprocessorMacroDefinition) {
|
||||
IASTName name = ((IASTPreprocessorMacroDefinition)statements[i]).getName();
|
||||
for (IASTPreprocessorStatement statement : statements) {
|
||||
if (statement instanceof IASTPreprocessorMacroDefinition) {
|
||||
IASTName name = ((IASTPreprocessorMacroDefinition)statement).getName();
|
||||
if (name != null) {
|
||||
mergeName(name);
|
||||
}
|
||||
|
@ -141,20 +141,20 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
|
||||
for(int i=0; i<nameList.size(); i++) {
|
||||
if (nameList.get(i) instanceof IASTName)
|
||||
namedArray[i] = (IASTName)nameList.get(i);
|
||||
namedArray[i] = nameList.get(i);
|
||||
}
|
||||
|
||||
return namedArray;
|
||||
}
|
||||
}
|
||||
|
||||
static protected class CPPNameCollector extends CPPASTVisitor {
|
||||
static protected class CPPNameCollector extends ASTVisitor {
|
||||
private static final int REGULAR_NAME_ADD = -1;
|
||||
private static final String BLANK_STRING = ""; //$NON-NLS-1$
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
public List<IASTName> nameList = new ArrayList<IASTName>();
|
||||
|
||||
String findString = null;
|
||||
boolean caseSensitive = true;
|
||||
|
@ -205,13 +205,14 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public int visit( IASTName name ){
|
||||
@Override
|
||||
public int visit( IASTName name ){
|
||||
return processName(name, REGULAR_NAME_ADD);
|
||||
}
|
||||
public IASTName getName( int idx ){
|
||||
if( idx < 0 || idx >= nameList.size() )
|
||||
return null;
|
||||
return (IASTName) nameList.get( idx );
|
||||
return nameList.get( idx );
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
|
||||
|
@ -232,9 +233,9 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
|
||||
public IASTName[] getNameArray(IASTPreprocessorStatement[] statements) {
|
||||
// first merge all of the preprocessor names into the array list
|
||||
for(int i=0; i<statements.length; i++) {
|
||||
if (statements[i] instanceof IASTPreprocessorMacroDefinition) {
|
||||
IASTName name = ((IASTPreprocessorMacroDefinition)statements[i]).getName();
|
||||
for (IASTPreprocessorStatement statement : statements) {
|
||||
if (statement instanceof IASTPreprocessorMacroDefinition) {
|
||||
IASTName name = ((IASTPreprocessorMacroDefinition)statement).getName();
|
||||
if (name != null) {
|
||||
mergeName(name);
|
||||
}
|
||||
|
@ -246,7 +247,7 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
|
||||
for(int i=0; i<nameList.size(); i++) {
|
||||
if (nameList.get(i) instanceof IASTName)
|
||||
namedArray[i] = (IASTName)nameList.get(i);
|
||||
namedArray[i] = nameList.get(i);
|
||||
}
|
||||
|
||||
return namedArray;
|
||||
|
@ -307,25 +308,25 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
}
|
||||
|
||||
private TreeItem expandTreeToTreeObject(TreeItem[] treeItems, DOMASTNodeLeaf treeObj) {
|
||||
for (int i=0; i<treeItems.length; i++) {
|
||||
if (treeItems[i].getData() == treeObj) {
|
||||
return treeItems[i];
|
||||
for (TreeItem treeItem : treeItems) {
|
||||
if (treeItem.getData() == treeObj) {
|
||||
return treeItem;
|
||||
}
|
||||
|
||||
DOMASTNodeParent parent = treeObj.getParent();
|
||||
|
||||
if (parent == null) return null;
|
||||
|
||||
while (parent != treeItems[i].getData()) {
|
||||
while (parent != treeItem.getData()) {
|
||||
parent = parent.getParent();
|
||||
if (parent == null) break;
|
||||
}
|
||||
|
||||
if (parent == treeItems[i].getData()) {
|
||||
treeItems[i].setExpanded(true);
|
||||
if (parent == treeItem.getData()) {
|
||||
treeItem.setExpanded(true);
|
||||
viewer.refresh();
|
||||
|
||||
return expandTreeToTreeObject(treeItems[i].getItems(), treeObj);
|
||||
return expandTreeToTreeObject(treeItem.getItems(), treeObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
|
@ -60,7 +59,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexName;
|
||||
|
||||
|
@ -246,26 +244,13 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
|||
}
|
||||
|
||||
private boolean isPointerOperatorEquals(IASTNode trailNode, IASTNode node) {
|
||||
if (trailNode instanceof IGPPASTPointer) {
|
||||
IGPPASTPointer trailGPointer = (IGPPASTPointer) trailNode;
|
||||
IGPPASTPointer gPointer = (IGPPASTPointer) node;
|
||||
if (trailNode instanceof IASTPointer) {
|
||||
IASTPointer trailGPointer = (IASTPointer) trailNode;
|
||||
IASTPointer gPointer = (IASTPointer) node;
|
||||
|
||||
return trailGPointer.isConst() == gPointer.isConst()
|
||||
&& trailGPointer.isRestrict() == gPointer.isRestrict()
|
||||
&& trailGPointer.isVolatile() == gPointer.isVolatile();
|
||||
} else if (trailNode instanceof ICASTPointer) {
|
||||
ICASTPointer trailCPointer = (ICASTPointer) trailNode;
|
||||
ICASTPointer cPointer = (ICASTPointer) node;
|
||||
|
||||
return trailCPointer.isConst() == cPointer.isConst()
|
||||
&& trailCPointer.isRestrict() == cPointer.isRestrict()
|
||||
&& trailCPointer.isVolatile() == cPointer.isVolatile();
|
||||
} else if (trailNode instanceof IASTPointer) {
|
||||
IASTPointer trailCPointer = (IASTPointer) trailNode;
|
||||
IASTPointer cPointer = (IASTPointer) node;
|
||||
|
||||
return trailCPointer.isConst() == cPointer.isConst()
|
||||
&& trailCPointer.isVolatile() == cPointer.isVolatile();
|
||||
} else {
|
||||
//same type
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue