1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 475739 - Treat C++ alignment-specifiers as attribute-specifiers

Change-Id: Ib8024a048073efe65c26c871bb3acd0f3bf2f620
Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
Nathan Ridge 2015-12-17 17:35:40 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent a43976b882
commit 393d36fc3e
61 changed files with 404 additions and 263 deletions

View file

@ -11249,6 +11249,12 @@ public class AST2CPPTests extends AST2TestBase {
public void testAlignas_451082() throws Exception {
parseAndCheckBindings();
}
// struct alignas(16) Node {};
// enum alignas(8) E { E1, E2 };
public void testAlignas_475739() throws Exception {
parseAndCheckBindings();
}
// int operator "" _A(unsigned long long i) { return 1; }
// int operator "" _B(long double d) { return 1; }

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.core.dom.ast;
/**
* Represents an alignment specifier.
*
* Grammatically, this is a decl-specifier.
* Grammatically, this is a decl-specifier in C and an attribute-specifier in C++.
*
* Possible forms are:
* C++:

View file

@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2015 Nathan Ridge.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
/**
* An attribute-specifier of the form [[ attribute-list ]] or __attribute__(( attribute-list )).
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @since 5.12
*/
public interface IASTAttributeList extends IASTAttributeSpecifier {
/**
* Returns the attributes in the list.
*/
@Override
public abstract IASTAttribute[] getAttributes();
/**
* Adds an attribute to the list.
*/
@Override
public abstract void addAttribute(IASTAttribute attribute);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2014, 2015 Institute for Software, HSR Hochschule fuer Technik and others
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -26,12 +26,16 @@ public interface IASTAttributeSpecifier extends IASTNode {
/**
* Returns the attributes of the specifier.
* @deprecated Use IASTAttributeList.getAttributes() instead.
*/
@Deprecated
public abstract IASTAttribute[] getAttributes();
/**
* Adds an attribute to the specifier.
* @deprecated Use IASTAttributeList.addAttribute() instead.
*/
@Deprecated
public abstract void addAttribute(IASTAttribute attribute);
@Override

View file

@ -30,7 +30,10 @@ public interface IASTDeclSpecifier extends IASTNode {
/** @since 5.2 */
public static final int sc_mutable = 6;
/** @since 5.10 */
/**
* @since 5.10
*/
@Deprecated
public static final ASTNodeProperty ALIGNMENT_SPECIFIER = new ASTNodeProperty(
"IASTDeclSpecifier.ALIGNMENT_SPECIFIER - Alignment specifier"); //$NON-NLS-1$
@ -53,8 +56,10 @@ public interface IASTDeclSpecifier extends IASTNode {
/**
* Get any alignment-specifiers in this decl-specifier sequence.
* @deprecated Alignment specifiers are now stored in the attribute specifier sequence.
* @since 5.10
*/
@Deprecated
public IASTAlignmentSpecifier[] getAlignmentSpecifiers();
/**
@ -97,8 +102,10 @@ public interface IASTDeclSpecifier extends IASTNode {
/**
* Not allowed on frozen ast.
* @deprecated Alignment specifiers are now stored in the attribute specifier sequence.
* @since 5.10
*/
@Deprecated
public void setAlignmentSpecifiers(IASTAlignmentSpecifier[] alignmentSpecifiers);
/**

View file

@ -15,7 +15,7 @@
package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeList;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IToken;
@ -122,8 +122,17 @@ public interface INodeFactory {
public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
/** @since 5.7 */
public IGCCASTAttributeSpecifier newGCCAttributeSpecifier();
/**
* @deprecated Use newGCCAttributeList() instead.
* @since 5.7
*/
@Deprecated
public org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier newGCCAttributeSpecifier();
/**
* @since 5.12
*/
public IGCCASTAttributeList newGCCAttributeList();
public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement);

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2015 Nathan Ridge.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
/**
* A C++ alignment-specifier.
*
* In the C++ grammar, an alignment-specifier is an attribute-specifier.
*
* @since 5.12
*/
public interface ICPPASTAlignmentSpecifier extends IASTAlignmentSpecifier, ICPPASTAttributeSpecifier {
@Override
public ICPPASTAlignmentSpecifier copy();
@Override
public ICPPASTAlignmentSpecifier copy(CopyStyle style);
}

View file

@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright (c) 2015 Nathan Ridge.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.IASTAttributeList;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
/**
* Represents a C++11 (ISO/IEC 14882:2011 7.6.1 [dcl.attr.grammar]) attribute specifier
* of the form [[ attribute-list ]].
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @since 5.12
*/
public interface ICPPASTAttributeList extends ICPPASTAttributeSpecifier, IASTAttributeList {
}

View file

@ -78,9 +78,16 @@ public interface ICPPNodeFactory extends INodeFactory {
public ICPPASTAttribute newAttribute(char[] name, char[] scope, IASTToken argumentClause, boolean packExpansion);
/**
* @deprecated Use newAttributeList() instead.
* @since 5.7
*/
@Deprecated
public ICPPASTAttributeSpecifier newAttributeSpecifier();
/**
* @since 5.12
*/
public ICPPASTAttributeList newAttributeList();
@Deprecated
public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual);

View file

@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2015 Nathan Ridge.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu;
import org.eclipse.cdt.core.dom.ast.IASTAttributeList;
import org.eclipse.cdt.core.dom.ast.IASTAttributeSpecifier;
import org.eclipse.cdt.core.parser.util.InstanceOfPredicate;
/**
* Represents a GCC attribute specifier, introduced by __attribute__.
*
* @since 5.12
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
@SuppressWarnings("deprecation")
public interface IGCCASTAttributeList extends IASTAttributeList, IGCCASTAttributeSpecifier {
public static InstanceOfPredicate<IASTAttributeSpecifier> TYPE_FILTER =
new InstanceOfPredicate<>(IGCCASTAttributeList.class);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2014, 2015 Institute for Software, HSR Hochschule fuer Technik and others
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -17,10 +17,12 @@ import org.eclipse.cdt.core.parser.util.InstanceOfPredicate;
/**
* Represents a GCC attribute specifier, introduced by __attribute__.
*
* @deprecated Use IGCCASTAttributeList instead.
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @since 5.7
*/
@Deprecated
public interface IGCCASTAttributeSpecifier extends IASTAttributeSpecifier {
public static InstanceOfPredicate<IASTAttributeSpecifier> TYPE_FILTER =
new InstanceOfPredicate<>(IGCCASTAttributeSpecifier.class);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2014, 2015 Institute for Software, HSR Hochschule fuer Technik and others
* Rapperswil, University of applied sciences.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -9,21 +9,21 @@
* Contributors:
* Thomas Corbat (IFS) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
import org.eclipse.cdt.core.dom.ast.IASTAttributeList;
import org.eclipse.cdt.core.dom.ast.IASTAttributeSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
* Represents an attribute specifier, containing attributes.
* Represents an attribute list, containing attributes.
*/
public abstract class ASTAttributeSpecifier extends ASTNode implements IASTAttributeSpecifier {
public abstract class ASTAttributeList extends ASTNode implements IASTAttributeList {
protected IASTAttribute[] attributes = IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
public ASTAttributeSpecifier() {
public ASTAttributeList() {
super();
}
@ -65,7 +65,7 @@ public abstract class ASTAttributeSpecifier extends ASTNode implements IASTAttri
return true;
}
protected <T extends ASTAttributeSpecifier> T copy(T copy, CopyStyle style) {
protected <T extends ASTAttributeList> T copy(T copy, CopyStyle style) {
copy.attributes = ArrayUtil.trim(attributes, true);
for (int i = 0; i < copy.attributes.length; i++) {
IASTAttribute attributeCopy = copy.attributes[i].copy(style);

View file

@ -12,10 +12,13 @@
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
import org.eclipse.cdt.core.dom.ast.IASTAttributeList;
import org.eclipse.cdt.core.dom.ast.IASTAttributeOwner;
import org.eclipse.cdt.core.dom.ast.IASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeList;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@ -29,7 +32,10 @@ public abstract class ASTAttributeOwner extends ASTNode implements IASTAttribute
public IASTAttribute[] getAttributes() {
IASTAttribute[] attributes = IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
for (IASTAttributeSpecifier attributeSpecifier : getAttributeSpecifiers()) {
attributes = ArrayUtil.addAll(attributes, attributeSpecifier.getAttributes());
if (attributeSpecifier instanceof IASTAttributeList) {
attributes = ArrayUtil.addAll(attributes,
((IASTAttributeList) attributeSpecifier).getAttributes());
}
}
return attributes;
}
@ -78,7 +84,7 @@ public abstract class ASTAttributeOwner extends ASTNode implements IASTAttribute
protected boolean acceptByGCCAttributeSpecifiers(ASTVisitor action) {
for (IASTAttributeSpecifier attributeSpecifier : attributeSpecifiers) {
if (!(attributeSpecifier instanceof IGCCASTAttributeSpecifier))
if (!(attributeSpecifier instanceof IGCCASTAttributeList))
continue;
if (!attributeSpecifier.accept(action))
return false;
@ -95,4 +101,21 @@ public abstract class ASTAttributeOwner extends ASTNode implements IASTAttribute
}
return true;
}
/*
* Having this here allows CPPASTAttributeOwner to implement IASTAmbiguityParent
* without needing to access the field attributeSpecifiers.
*/
protected void replace(IASTNode child, IASTNode other) {
if (child instanceof IASTAlignmentSpecifier && other instanceof IASTAlignmentSpecifier) {
for (int i = 0; i < attributeSpecifiers.length; ++i) {
if (attributeSpecifiers[i] == child) {
attributeSpecifiers[i] = (IASTAttributeSpecifier) other;
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
return;
}
}
}
}
}

View file

@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
import org.eclipse.cdt.core.dom.ast.IASTAttributeList;
import org.eclipse.cdt.core.dom.ast.IASTAttributeOwner;
import org.eclipse.cdt.core.dom.ast.IASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
@ -2384,11 +2385,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
* @throws BacktrackException
* @throws EndOfFileException
*/
protected IASTAttributeSpecifier __attribute__() throws BacktrackException, EndOfFileException {
protected IASTAttributeList __attribute__() throws BacktrackException, EndOfFileException {
if (LT(1) != IGCCToken.t__attribute__)
return null;
IASTAttributeSpecifier result = nodeFactory.newGCCAttributeSpecifier();
IASTAttributeList result = nodeFactory.newGCCAttributeList();
consume();
if (LT(1) == IToken.tLPAREN) {
consume();

View file

@ -11,20 +11,19 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeList;
/**
* Represents a GCC attribute specifier, containing attributes.
* Represents a GCC attribute list, containing attributes.
*/
public class GCCASTAttributeSpecifier extends ASTAttributeSpecifier implements IGCCASTAttributeSpecifier {
public class GCCASTAttributeList extends ASTAttributeList implements IGCCASTAttributeList {
@Override
public GCCASTAttributeSpecifier copy(CopyStyle style) {
return copy(new GCCASTAttributeSpecifier(), style);
public GCCASTAttributeList copy(CopyStyle style) {
return copy(new GCCASTAttributeList(), style);
}
@Override
public GCCASTAttributeSpecifier copy() {
public GCCASTAttributeList copy() {
return copy(CopyStyle.withoutLocations);
}
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.INodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeList;
/**
* Abstract base class for node factories.
@ -34,4 +35,15 @@ public abstract class NodeFactory implements INodeFactory {
ASTNode e= (ASTNode) endNode;
a.setLength(e.getOffset() + e.getLength() - a.getOffset());
}
@Deprecated
@Override
public org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier newGCCAttributeSpecifier() {
return new GCCASTAttributeList();
}
@Override
public IGCCASTAttributeList newGCCAttributeList() {
return new GCCASTAttributeList();
}
}

View file

@ -81,14 +81,12 @@ 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.c.ICASTTypedefNameSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICNodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
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.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.ASTToken;
import org.eclipse.cdt.internal.core.dom.parser.ASTTokenList;
import org.eclipse.cdt.internal.core.dom.parser.GCCASTAttributeSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
@ -299,11 +297,6 @@ public class CNodeFactory extends NodeFactory implements ICNodeFactory {
return new CASTFunctionDefinition(declSpecifier, declarator, bodyStatement);
}
@Override
public IGCCASTAttributeSpecifier newGCCAttributeSpecifier() {
return new GCCASTAttributeSpecifier();
}
@Override
public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) {
return new CASTCompoundStatementExpression(compoundStatement);
@ -489,21 +482,4 @@ public class CNodeFactory extends NodeFactory implements ICNodeFactory {
public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
return new CASTWhileStatement(condition, body);
}
}
}

View file

@ -15,9 +15,8 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
public class CPPASTAliasDeclaration extends ASTAttributeOwner implements ICPPASTAliasDeclaration {
public class CPPASTAliasDeclaration extends CPPASTAttributeOwner implements ICPPASTAliasDeclaration {
private IASTName aliasName;
private ICPPASTTypeId mappingTypeId;

View file

@ -11,14 +11,15 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAlignmentSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CPPASTAlignmentSpecifier extends ASTNode implements IASTAlignmentSpecifier,
public class CPPASTAlignmentSpecifier extends ASTNode implements ICPPASTAlignmentSpecifier,
IASTAmbiguityParent {
// Precisely one of these is null.
private IASTExpression fExpression;
@ -47,12 +48,12 @@ public class CPPASTAlignmentSpecifier extends ASTNode implements IASTAlignmentSp
}
@Override
public IASTAlignmentSpecifier copy() {
public ICPPASTAlignmentSpecifier copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public IASTAlignmentSpecifier copy(CopyStyle style) {
public ICPPASTAlignmentSpecifier copy(CopyStyle style) {
CPPASTAlignmentSpecifier copy;
if (fExpression != null) {
copy = new CPPASTAlignmentSpecifier(fExpression.copy(style));
@ -82,4 +83,15 @@ public class CPPASTAlignmentSpecifier extends ASTNode implements IASTAlignmentSp
other.setPropertyInParent(child.getPropertyInParent());
}
}
@Deprecated
@Override
public IASTAttribute[] getAttributes() {
return null;
}
@Deprecated
@Override
public void addAttribute(IASTAttribute attribute) {
}
}

View file

@ -11,12 +11,14 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAlignmentSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
public class CPPASTAmbiguousAlignmentSpecifier extends ASTAmbiguousNode implements IASTAlignmentSpecifier {
public class CPPASTAmbiguousAlignmentSpecifier extends ASTAmbiguousNode implements ICPPASTAlignmentSpecifier {
IASTAlignmentSpecifier fExpression;
IASTAlignmentSpecifier fTypeId;
@ -36,12 +38,12 @@ public class CPPASTAmbiguousAlignmentSpecifier extends ASTAmbiguousNode implemen
}
@Override
public IASTAlignmentSpecifier copy() {
public ICPPASTAlignmentSpecifier copy() {
throw new UnsupportedOperationException();
}
@Override
public IASTAlignmentSpecifier copy(CopyStyle style) {
public ICPPASTAlignmentSpecifier copy(CopyStyle style) {
throw new UnsupportedOperationException();
}
@ -49,4 +51,15 @@ public class CPPASTAmbiguousAlignmentSpecifier extends ASTAmbiguousNode implemen
public IASTNode[] getNodes() {
return new IASTNode[] { fExpression, fTypeId };
}
@Deprecated
@Override
public IASTAttribute[] getAttributes() {
return null;
}
@Deprecated
@Override
public void addAttribute(IASTAttribute attribute) {
}
}

View file

@ -16,13 +16,11 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
public class CPPASTArrayModifier extends ASTAttributeOwner implements IASTArrayModifier, IASTAmbiguityParent {
public class CPPASTArrayModifier extends CPPASTAttributeOwner implements IASTArrayModifier {
private IASTExpression exp;
public CPPASTArrayModifier() {
@ -85,6 +83,8 @@ public class CPPASTArrayModifier extends ASTAttributeOwner implements IASTArrayM
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
exp = (IASTExpression) other;
return;
}
super.replace(child, other);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2014, 2015 Institute for Software, HSR Hochschule fuer Technik and others
* Rapperswil, University of applied sciences.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -11,19 +11,20 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttributeList;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeList;
/**
* Represents a C++ attribute specifier, containing attributes.
* Represents a C++ attribute list, containing attributes.
*/
public class CPPASTAttributeSpecifier extends ASTAttributeSpecifier implements ICPPASTAttributeSpecifier {
public class CPPASTAttributeList extends ASTAttributeList implements ICPPASTAttributeList {
@Override
public CPPASTAttributeSpecifier copy(CopyStyle style) {
return copy(new CPPASTAttributeSpecifier(), style);
public CPPASTAttributeList copy(CopyStyle style) {
return copy(new CPPASTAttributeList(), style);
}
@Override
public CPPASTAttributeSpecifier copy() {
public CPPASTAttributeList copy() {
return copy(CopyStyle.withoutLocations);
}
}

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2015 Nathan Ridge.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
/**
* C++ attribute owners.
*
* These implement IASTAmbiguityParent because in C++ an attribute-specifier
* can be an alignment-specifier, and an alignment-specifier can be an
* ambiguous node.
*/
public abstract class CPPASTAttributeOwner extends ASTAttributeOwner implements IASTAmbiguityParent {
@Override
public void replace(IASTNode child, IASTNode other) {
super.replace(child, other);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2014 IBM Corporation and others.
* Copyright (c) 2004, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -11,19 +11,14 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
/**
* Base for all c++ declaration specifiers.
*/
public abstract class CPPASTBaseDeclSpecifier extends ASTAttributeOwner
implements ICPPASTDeclSpecifier, IASTAmbiguityParent {
public abstract class CPPASTBaseDeclSpecifier extends CPPASTAttributeOwner implements ICPPASTDeclSpecifier {
private boolean explicit;
private boolean friend;
private boolean inline;
@ -34,8 +29,6 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTAttributeOwner
private boolean isVolatile;
private int sc;
private boolean virtual;
private IASTAlignmentSpecifier[] alignmentSpecifiers =
IASTAlignmentSpecifier.EMPTY_ALIGNMENT_SPECIFIER_ARRAY;
@Override
public boolean isFriend() {
@ -147,19 +140,15 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTAttributeOwner
this.explicit = value;
}
@Deprecated
@Override
public IASTAlignmentSpecifier[] getAlignmentSpecifiers() {
return alignmentSpecifiers;
return null;
}
@Deprecated
@Override
public void setAlignmentSpecifiers(IASTAlignmentSpecifier[] alignmentSpecifiers) {
assertNotFrozen();
for (IASTAlignmentSpecifier specifier : alignmentSpecifiers) {
specifier.setParent(this);
specifier.setPropertyInParent(ALIGNMENT_SPECIFIER);
}
this.alignmentSpecifiers = alignmentSpecifiers;
}
protected <T extends CPPASTBaseDeclSpecifier> T copy(T copy, CopyStyle style) {
@ -174,11 +163,6 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTAttributeOwner
target.isVolatile = isVolatile;
target.sc = sc;
target.virtual = virtual;
target.alignmentSpecifiers = new IASTAlignmentSpecifier[alignmentSpecifiers.length];
for (int i = 0; i < alignmentSpecifiers.length; ++i) {
target.alignmentSpecifiers[i] = alignmentSpecifiers[i].copy(style);
target.alignmentSpecifiers[i].setParent(target);
}
return super.copy(copy, style);
}
@ -189,27 +173,4 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTAttributeOwner
public String toString() {
return ASTStringUtil.getSignatureString(this, null);
}
protected boolean visitAlignmentSpecifiers(ASTVisitor visitor) {
for (IASTAlignmentSpecifier specifier : alignmentSpecifiers) {
if (!specifier.accept(visitor)) {
return false;
}
}
return true;
}
@Override
public void replace(IASTNode child, IASTNode other) {
if (child instanceof IASTAlignmentSpecifier && other instanceof IASTAlignmentSpecifier) {
for (int i = 0; i < alignmentSpecifiers.length; ++i) {
if (alignmentSpecifiers[i] == child) {
alignmentSpecifiers[i] = (IASTAlignmentSpecifier) other;
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
return;
}
}
}
}
}

View file

@ -13,12 +13,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
/**
* @author jcamelon
*/
public class CPPASTBreakStatement extends ASTAttributeOwner implements IASTBreakStatement {
public class CPPASTBreakStatement extends CPPASTAttributeOwner implements IASTBreakStatement {
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitStatements) {

View file

@ -15,14 +15,11 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
public class CPPASTCaseStatement extends ASTAttributeOwner
implements IASTCaseStatement, IASTAmbiguityParent {
public class CPPASTCaseStatement extends CPPASTAttributeOwner implements IASTCaseStatement {
private IASTExpression expression;
public CPPASTCaseStatement() {
@ -88,6 +85,8 @@ public class CPPASTCaseStatement extends ASTAttributeOwner
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
expression = (IASTExpression) other;
return;
}
super.replace(child, other);
}
}

View file

@ -19,15 +19,12 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.DestructorCallCollector;
/**
* @author jcamelon
*/
public class CPPASTCatchHandler extends ASTAttributeOwner
implements ICPPASTCatchHandler, IASTAmbiguityParent {
public class CPPASTCatchHandler extends CPPASTAttributeOwner implements ICPPASTCatchHandler {
private boolean fIsCatchAll;
private IASTStatement fBody;
private IASTDeclaration fDeclaration;
@ -139,12 +136,15 @@ public class CPPASTCatchHandler extends ASTAttributeOwner
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
fBody = (IASTStatement) other;
return;
}
if (fDeclaration == child) {
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
fDeclaration = (IASTDeclaration) other;
return;
}
super.replace(child, other);
}
@Override

View file

@ -182,10 +182,6 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
if (!acceptByAttributeSpecifiers(action))
return false;
if (!visitAlignmentSpecifiers(action)) {
return false;
}
if (fName != null && !fName.accept(action))
return false;

View file

@ -19,15 +19,12 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.DestructorCallCollector;
/**
* @author jcamelon
*/
public class CPPASTCompoundStatement extends ASTAttributeOwner
implements ICPPASTCompoundStatement, IASTAmbiguityParent {
public class CPPASTCompoundStatement extends CPPASTAttributeOwner implements ICPPASTCompoundStatement {
private IASTStatement[] statements = new IASTStatement[2];
private ICPPScope scope;
private IASTImplicitDestructorName[] fImplicitDestructorNames;
@ -118,7 +115,9 @@ public class CPPASTCompoundStatement extends ASTAttributeOwner
other.setParent(statements[i].getParent());
other.setPropertyInParent(statements[i].getPropertyInParent());
statements[i] = (IASTStatement) other;
return;
}
}
super.replace(child, other);
}
}

View file

@ -13,12 +13,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
/**
* @author jcamelon
*/
public class CPPASTContinueStatement extends ASTAttributeOwner implements IASTContinueStatement {
public class CPPASTContinueStatement extends CPPASTAttributeOwner implements IASTContinueStatement {
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitStatements) {

View file

@ -34,18 +34,16 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/**
* C++ specific declarator.
*/
public class CPPASTDeclarator extends ASTAttributeOwner implements ICPPASTDeclarator, IASTImplicitNameOwner,
IASTAmbiguityParent {
public class CPPASTDeclarator extends CPPASTAttributeOwner implements ICPPASTDeclarator,
IASTImplicitNameOwner {
private IASTInitializer initializer;
private IASTName name;
private IASTImplicitName[] implicitNames;
@ -301,6 +299,8 @@ public class CPPASTDeclarator extends ASTAttributeOwner implements ICPPASTDeclar
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
nested= (IASTDeclarator) other;
return;
}
super.replace(child, other);
}
}

View file

@ -13,12 +13,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
/**
* @author jcamelon
*/
public class CPPASTDefaultStatement extends ASTAttributeOwner implements IASTDefaultStatement {
public class CPPASTDefaultStatement extends CPPASTAttributeOwner implements IASTDefaultStatement {
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitStatements) {

View file

@ -16,14 +16,11 @@ import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
public class CPPASTDoStatement extends ASTAttributeOwner
implements IASTDoStatement, IASTAmbiguityParent {
public class CPPASTDoStatement extends CPPASTAttributeOwner implements IASTDoStatement {
private IASTStatement body;
private IASTExpression condition;
@ -108,11 +105,14 @@ public class CPPASTDoStatement extends ASTAttributeOwner
other.setPropertyInParent(body.getPropertyInParent());
other.setParent(body.getParent());
body = (IASTStatement) other;
return;
}
if (child == condition) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
condition = (IASTExpression) other;
return;
}
super.replace(child, other);
}
}

View file

@ -90,10 +90,6 @@ public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier
if (!acceptByAttributeSpecifiers(action))
return false;
if (!visitAlignmentSpecifiers(action)) {
return false;
}
if (name != null) if (!name.accept(action)) return false;
if (action.shouldVisitDeclSpecifiers) {
switch (action.leave(this)) {

View file

@ -135,10 +135,6 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
if (!acceptByAttributeSpecifiers(action))
return false;
if (!visitAlignmentSpecifiers(action)) {
return false;
}
for (IASTEnumerator e : getEnumerators()) {
if (!e.accept(action))
return false;

View file

@ -15,14 +15,11 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
public class CPPASTExpressionStatement extends ASTAttributeOwner
implements IASTExpressionStatement, IASTAmbiguityParent {
public class CPPASTExpressionStatement extends CPPASTAttributeOwner implements IASTExpressionStatement {
private IASTExpression expression;
public CPPASTExpressionStatement() {
@ -88,6 +85,8 @@ public class CPPASTExpressionStatement extends ASTAttributeOwner
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
expression = (IASTExpression) other;
return;
}
super.replace(child, other);
}
}

View file

@ -22,14 +22,12 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.DestructorCallCollector;
/**
* For statement in C++
*/
public class CPPASTForStatement extends ASTAttributeOwner
implements ICPPASTForStatement, IASTAmbiguityParent {
public class CPPASTForStatement extends CPPASTAttributeOwner implements ICPPASTForStatement {
private IScope fScope;
private IASTStatement fInit;
@ -173,21 +171,26 @@ public class CPPASTForStatement extends ASTAttributeOwner
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
fBody = (IASTStatement) other;
return;
} else if (child == fCondition || child == fCondDeclaration) {
if (other instanceof IASTExpression) {
setConditionExpression((IASTExpression) other);
} else if (other instanceof IASTDeclaration) {
setConditionDeclaration((IASTDeclaration) other);
}
return;
} else if (child == fIterationExpression) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
fIterationExpression = (IASTExpression) other;
return;
} else if (child == fInit) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
fInit = (IASTStatement) other;
return;
}
super.replace(child, other);
}
@Override

View file

@ -34,17 +34,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* Models a function definition without a try-block. If used for a constructor definition
* it may contain member initializers.
*/
public class CPPASTFunctionDefinition extends ASTAttributeOwner
implements ICPPASTFunctionDefinition, IASTAmbiguityParent, IASTImplicitNameOwner {
public class CPPASTFunctionDefinition extends CPPASTAttributeOwner
implements ICPPASTFunctionDefinition, IASTImplicitNameOwner {
private IASTDeclSpecifier declSpecifier;
private IASTFunctionDeclarator declarator;
private IASTStatement bodyStatement;
@ -245,7 +243,9 @@ public class CPPASTFunctionDefinition extends ASTAttributeOwner
other.setPropertyInParent(bodyStatement.getPropertyInParent());
other.setParent(bodyStatement.getParent());
bodyStatement = (IASTStatement) other;
return;
}
super.replace(child, other);
}
@Override

View file

@ -14,12 +14,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
/**
* @author jcamelon
*/
public class CPPASTGotoStatement extends ASTAttributeOwner implements IASTGotoStatement {
public class CPPASTGotoStatement extends CPPASTAttributeOwner implements IASTGotoStatement {
private IASTName name;
public CPPASTGotoStatement() {

View file

@ -20,13 +20,11 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* If statement in C++
*/
public class CPPASTIfStatement extends ASTAttributeOwner implements ICPPASTIfStatement, IASTAmbiguityParent {
public class CPPASTIfStatement extends CPPASTAttributeOwner implements ICPPASTIfStatement {
private IASTExpression condition;
private IASTStatement thenClause;
private IASTStatement elseClause;
@ -177,17 +175,21 @@ public class CPPASTIfStatement extends ASTAttributeOwner implements ICPPASTIfSta
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
thenClause = (IASTStatement) other;
return;
} else if (elseClause == child) {
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
elseClause = (IASTStatement) other;
return;
} else if (condition == child || condDecl == child) {
if (other instanceof IASTExpression) {
setConditionExpression((IASTExpression) other);
} else if (other instanceof IASTDeclaration) {
setConditionDeclaration((IASTDeclaration) other);
}
return;
}
super.replace(child, other);
}
@Override

View file

@ -16,14 +16,11 @@ import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
public class CPPASTLabelStatement extends ASTAttributeOwner
implements IASTLabelStatement, IASTAmbiguityParent {
public class CPPASTLabelStatement extends CPPASTAttributeOwner implements IASTLabelStatement {
private IASTName name;
private IASTStatement nestedStatement;
@ -114,6 +111,8 @@ public class CPPASTLabelStatement extends ASTAttributeOwner
other.setParent(this);
other.setPropertyInParent(child.getPropertyInParent());
setNestedStatement((IASTStatement) other);
return;
}
super.replace(child, other);
}
}

View file

@ -90,10 +90,6 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier
}
}
if (!visitAlignmentSpecifiers(action)) {
return false;
}
if (name != null && !name.accept(action))
return false;

View file

@ -20,15 +20,12 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* Definition of a namespace.
*/
public class CPPASTNamespaceDefinition extends ASTAttributeOwner
implements ICPPASTNamespaceDefinition, IASTAmbiguityParent {
public class CPPASTNamespaceDefinition extends CPPASTAttributeOwner implements ICPPASTNamespaceDefinition {
private IASTName fName;
private IASTDeclaration[] fAllDeclarations;
private IASTDeclaration[] fActiveDeclarations;
@ -162,8 +159,9 @@ public class CPPASTNamespaceDefinition extends ASTAttributeOwner
other.setPropertyInParent(child.getPropertyInParent());
fAllDeclarations[i] = (IASTDeclaration) other;
fActiveDeclarations= null;
break;
return;
}
}
super.replace(child, other);
}
}

View file

@ -13,12 +13,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
/**
* @author jcamelon
*/
public class CPPASTNullStatement extends ASTAttributeOwner implements IASTNullStatement {
public class CPPASTNullStatement extends CPPASTAttributeOwner implements IASTNullStatement {
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitStatements) {

View file

@ -14,12 +14,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTPointer;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
/**
* A pointer operator of a declarator
*/
public class CPPASTPointer extends ASTAttributeOwner implements IASTPointer {
public class CPPASTPointer extends CPPASTAttributeOwner implements IASTPointer {
private boolean isConst;
private boolean isVolatile;
private boolean isRestrict;

View file

@ -27,9 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.DestructorCallCollector;
@ -38,8 +36,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
/**
* Range based 'for' loop in C++.
*/
public class CPPASTRangeBasedForStatement extends ASTAttributeOwner
implements ICPPASTRangeBasedForStatement, IASTAmbiguityParent {
public class CPPASTRangeBasedForStatement extends CPPASTAttributeOwner implements ICPPASTRangeBasedForStatement {
private IScope fScope;
private IASTDeclaration fDeclaration;
private IASTInitializerClause fInitClause;
@ -223,10 +220,14 @@ public class CPPASTRangeBasedForStatement extends ASTAttributeOwner
public void replace(IASTNode child, IASTNode other) {
if (child == fDeclaration) {
setDeclaration((IASTDeclaration) other);
return;
} else if (child == fInitClause) {
setInitializerClause((IASTInitializerClause) other);
return;
} else if (child == fBody) {
setBody((IASTStatement) other);
return;
}
super.replace(child, other);
}
}

View file

@ -14,12 +14,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
/**
* Reference operator for declarators.
*/
public class CPPASTReferenceOperator extends ASTAttributeOwner implements ICPPASTReferenceOperator {
public class CPPASTReferenceOperator extends CPPASTAttributeOwner implements ICPPASTReferenceOperator {
private final boolean fIsRValue;
public CPPASTReferenceOperator(boolean isRValueReference) {

View file

@ -17,10 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CPPASTReturnStatement extends ASTAttributeOwner implements IASTReturnStatement, IASTAmbiguityParent {
public class CPPASTReturnStatement extends CPPASTAttributeOwner implements IASTReturnStatement {
private IASTInitializerClause retValue;
public CPPASTReturnStatement() {
@ -99,6 +97,8 @@ public class CPPASTReturnStatement extends ASTAttributeOwner implements IASTRetu
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
retValue = (IASTInitializerClause) other;
return;
}
super.replace(child, other);
}
}

View file

@ -222,10 +222,6 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
if (!acceptByAttributeSpecifiers(action))
return false;
if (!visitAlignmentSpecifiers(action)) {
return false;
}
if (action.shouldVisitDeclSpecifiers) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;

View file

@ -18,14 +18,11 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
public class CPPASTSimpleDeclaration extends ASTAttributeOwner
implements IASTSimpleDeclaration, IASTAmbiguityParent {
public class CPPASTSimpleDeclaration extends CPPASTAttributeOwner implements IASTSimpleDeclaration {
private IASTDeclarator[] declarators;
private int declaratorsPos = -1;
private IASTDeclSpecifier declSpecifier;
@ -124,8 +121,9 @@ public class CPPASTSimpleDeclaration extends ASTAttributeOwner
declarators[i] = (IASTDeclarator) other;
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
break;
return;
}
}
super.replace(child, other);
}
}

View file

@ -19,14 +19,11 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSwitchStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* Switch statement in C++.
*/
public class CPPASTSwitchStatement extends ASTAttributeOwner
implements ICPPASTSwitchStatement, IASTAmbiguityParent {
public class CPPASTSwitchStatement extends CPPASTAttributeOwner implements ICPPASTSwitchStatement {
private IScope scope;
private IASTExpression controllerExpression;
private IASTDeclaration controllerDeclaration;
@ -123,13 +120,16 @@ public class CPPASTSwitchStatement extends ASTAttributeOwner
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
body = (IASTStatement) other;
return;
} else if (controllerDeclaration == child || controllerExpression == child) {
if (other instanceof IASTExpression) {
setControllerExpression((IASTExpression) other);
} else if (other instanceof IASTDeclaration) {
setControllerDeclaration((IASTDeclaration) other);
}
return;
}
super.replace(child, other);
}
@Override

View file

@ -18,13 +18,11 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
public class CPPASTTryBlockStatement extends ASTAttributeOwner implements ICPPASTTryBlockStatement, IASTAmbiguityParent {
public class CPPASTTryBlockStatement extends CPPASTAttributeOwner implements ICPPASTTryBlockStatement {
private ICPPASTCatchHandler[] catchHandlers;
private int catchHandlersPos= -1;
private IASTStatement tryBody;
@ -119,6 +117,8 @@ public class CPPASTTryBlockStatement extends ASTAttributeOwner implements ICPPAS
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
tryBody = (IASTStatement) other;
return;
}
super.replace(child, other);
}
}

View file

@ -61,10 +61,6 @@ public class CPPASTTypeTransformationSpecifier extends CPPASTBaseDeclSpecifier i
}
}
if (!visitAlignmentSpecifiers(action)) {
return false;
}
if (!fOperand.accept(action))
return false;

View file

@ -22,10 +22,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
public class CPPASTUsingDeclaration extends ASTAttributeOwner
public class CPPASTUsingDeclaration extends CPPASTAttributeOwner
implements ICPPASTUsingDeclaration, ICPPASTCompletionContext {
private boolean typeName;
private IASTName name;

View file

@ -22,10 +22,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
public class CPPASTUsingDirective extends ASTAttributeOwner
public class CPPASTUsingDirective extends CPPASTAttributeOwner
implements ICPPASTUsingDirective, ICPPASTCompletionContext {
private IASTName name;

View file

@ -19,14 +19,11 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* While statement in C++.
*/
public class CPPASTWhileStatement extends ASTAttributeOwner
implements ICPPASTWhileStatement, IASTAmbiguityParent {
public class CPPASTWhileStatement extends CPPASTAttributeOwner implements ICPPASTWhileStatement {
private IASTExpression condition;
private IASTDeclaration condition2;
private IASTStatement body;
@ -136,6 +133,7 @@ public class CPPASTWhileStatement extends ASTAttributeOwner
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
body = (IASTStatement) other;
return;
}
if (child == condition || child == condition2) {
if (other instanceof IASTExpression) {
@ -143,7 +141,9 @@ public class CPPASTWhileStatement extends ASTAttributeOwner
} else if (other instanceof IASTDeclaration) {
setConditionDeclaration((IASTDeclaration) other);
}
return;
}
super.replace(child, other);
}
@Override

View file

@ -59,6 +59,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttribute;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttributeList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
@ -129,14 +130,12 @@ 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.cpp.ICPPUnaryTypeTransformation;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.ASTToken;
import org.eclipse.cdt.internal.core.dom.parser.ASTTokenList;
import org.eclipse.cdt.internal.core.dom.parser.GCCASTAttributeSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
@ -211,9 +210,15 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new CPPASTAttribute(name, scope, argumentClause, packExpansion);
}
@Deprecated
@Override
public ICPPASTAttributeSpecifier newAttributeSpecifier() {
return new CPPASTAttributeSpecifier();
return new CPPASTAttributeList();
}
@Override
public ICPPASTAttributeList newAttributeList() {
return new CPPASTAttributeList();
}
@Override
@ -469,11 +474,6 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new CPPASTFunctionWithTryBlock(declSpecifier, declarator, bodyStatement);
}
@Override
public IGCCASTAttributeSpecifier newGCCAttributeSpecifier() {
return new GCCASTAttributeSpecifier();
}
@Override
public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) {
return new CPPASTCompoundStatementExpression(compoundStatement);

View file

@ -14,7 +14,6 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTGotoStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
/**
* GNU C++ goto statement.
@ -27,7 +26,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
*
* @since 5.8
*/
public class GNUCPPASTGotoStatement extends ASTAttributeOwner implements IGNUASTGotoStatement {
public class GNUCPPASTGotoStatement extends CPPASTAttributeOwner implements IGNUASTGotoStatement {
private IASTExpression expression;
public GNUCPPASTGotoStatement() {

View file

@ -73,10 +73,12 @@ import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttribute;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttributeList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
@ -147,7 +149,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.EndOfFileException;
@ -2577,23 +2578,28 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
BacktrackException {
List<IASTAttributeSpecifier> specifiers = null;
while (LTcatchEOF(1) == IToken.tLBRACKET && LTcatchEOF(2) == IToken.tLBRACKET) {
while ((LTcatchEOF(1) == IToken.tLBRACKET && LTcatchEOF(2) == IToken.tLBRACKET) ||
LTcatchEOF(1) == IToken.t_alignas) {
if (specifiers == null)
specifiers = new ArrayList<>();
int offset = consumeOrEOC(IToken.tLBRACKET).getOffset();
consumeOrEOC(IToken.tLBRACKET);
ICPPASTAttributeSpecifier attributeSpecifier = getNodeFactory().newAttributeSpecifier();
while (LT(1) != IToken.tRBRACKET) {
if (LT(1) == IToken.tCOMMA)
consume();
ICPPASTAttribute attribute = singleAttribute();
attributeSpecifier.addAttribute(attribute);
if (LTcatchEOF(1) == IToken.t_alignas) {
specifiers.add((ICPPASTAlignmentSpecifier) alignmentSpecifier());
} else {
int offset = consumeOrEOC(IToken.tLBRACKET).getOffset();
consumeOrEOC(IToken.tLBRACKET);
ICPPASTAttributeList attributeList = getNodeFactory().newAttributeList();
while (LT(1) != IToken.tRBRACKET) {
if (LT(1) == IToken.tCOMMA)
consume();
ICPPASTAttribute attribute = singleAttribute();
attributeList.addAttribute(attribute);
}
consumeOrEOC(IToken.tRBRACKET);
int endOffset = consumeOrEOC(IToken.tRBRACKET).getEndOffset();
setRange(attributeList, offset, endOffset);
specifiers.add(attributeList);
}
consumeOrEOC(IToken.tRBRACKET);
int endOffset = consumeOrEOC(IToken.tRBRACKET).getEndOffset();
setRange(attributeSpecifier, offset, endOffset);
specifiers.add(attributeSpecifier);
}
return specifiers;
}
@ -2970,7 +2976,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
ICPPASTDeclSpecifier result= null;
ICPPASTDeclSpecifier altResult= null;
List<IASTAttributeSpecifier> attributes = null;
IASTAlignmentSpecifier[] alignmentSpecifiers = IASTAlignmentSpecifier.EMPTY_ALIGNMENT_SPECIFIER_ARRAY;
try {
IASTName identifier= null;
IASTExpression typeofExpression= null;
@ -3259,10 +3264,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
encounteredTypename= true;
break;
case IToken.t_alignas:
alignmentSpecifiers = ArrayUtil.append(alignmentSpecifiers, alignmentSpecifier());
break;
case IGCCToken.t__attribute__: // if __attribute__ is after the declSpec
if (!supportAttributeSpecifiers)
throwBacktrack(LA(1));
@ -3362,7 +3363,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
result= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
}
addAttributeSpecifiers(attributes, result);
result.setAlignmentSpecifiers(ArrayUtil.trim(alignmentSpecifiers));
} catch (BacktrackException e) {
if (returnToken != null) {
backup(returnToken);

View file

@ -11,14 +11,16 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
import org.eclipse.cdt.core.dom.ast.IASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTToken;
import org.eclipse.cdt.core.dom.ast.IASTTokenList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttribute;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttributeList;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeList;
import org.eclipse.cdt.core.parser.GCCKeywords;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAttribute;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -36,14 +38,27 @@ public class AttributeWriter extends NodeWriter {
}
public void writeAttributeSpecifier(IASTAttributeSpecifier attribute) {
if (attribute instanceof ICPPASTAttributeSpecifier) {
writeAttributeSpecifier((ICPPASTAttributeSpecifier) attribute);
} else if (attribute instanceof IGCCASTAttributeSpecifier) {
writeGCCAttributeSpecifier((IGCCASTAttributeSpecifier) attribute);
if (attribute instanceof ICPPASTAttributeList) {
writeAttributeSpecifier((ICPPASTAttributeList) attribute);
} else if (attribute instanceof IGCCASTAttributeList) {
writeGCCAttributeSpecifier((IGCCASTAttributeList) attribute);
} else if (attribute instanceof IASTAlignmentSpecifier) {
writeAlignmentSpecifier((IASTAlignmentSpecifier) attribute);
}
}
private void writeAlignmentSpecifier(IASTAlignmentSpecifier specifier) {
scribe.print(Keywords.ALIGNAS);
scribe.print(OPENING_PARENTHESIS);
if (specifier.getExpression() != null) {
specifier.getExpression().accept(visitor);
} else if (specifier.getTypeId() != null) {
specifier.getTypeId().accept(visitor);
}
scribe.print(CLOSING_PARENTHESIS);
}
private void writeGCCAttributeSpecifier(IGCCASTAttributeSpecifier specifier) {
private void writeGCCAttributeSpecifier(IGCCASTAttributeList specifier) {
scribe.print(GCCKeywords.__ATTRIBUTE__);
scribe.print(OPENING_PARENTHESIS);
scribe.print(OPENING_PARENTHESIS);
@ -60,7 +75,7 @@ public class AttributeWriter extends NodeWriter {
scribe.print(CLOSING_PARENTHESIS);
}
private void writeAttributeSpecifier(ICPPASTAttributeSpecifier specifier) {
private void writeAttributeSpecifier(ICPPASTAttributeList specifier) {
scribe.print(OPENING_SQUARE_BRACKET);
scribe.print(OPENING_SQUARE_BRACKET);
IASTAttribute[] innerAttributes = specifier.getAttributes();

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTAttributeOwner;
import org.eclipse.cdt.core.dom.ast.IASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeList;
import org.eclipse.cdt.core.dom.parser.cpp.ICPPASTAttributeSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -127,7 +127,7 @@ public class NodeWriter {
protected void writeGCCAttributes(IASTAttributeOwner attributeOwner, EnumSet<SpaceLocation> spaceLocations) {
IASTAttributeSpecifier[] specifiers = attributeOwner.getAttributeSpecifiers();
IASTAttributeSpecifier[] gnuSpecifiers = ArrayUtil.filter(specifiers, IGCCASTAttributeSpecifier.TYPE_FILTER);
IASTAttributeSpecifier[] gnuSpecifiers = ArrayUtil.filter(specifiers, IGCCASTAttributeList.TYPE_FILTER);
writeAttributes(gnuSpecifiers, spaceLocations);
}