mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 327300. Parsing support for noexcept operators and noexcept
specifications in function declarators. Adjustments for CDT 8.1.x.
This commit is contained in:
parent
d89b672a97
commit
ae8af8e02f
7 changed files with 31 additions and 21 deletions
|
@ -30,6 +30,13 @@
|
|||
</message_arguments>
|
||||
</filter>
|
||||
</resource>
|
||||
<resource path="parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java" type="org.eclipse.cdt.core.dom.ast.IASTUnaryExpression">
|
||||
<filter id="1211105284">
|
||||
<message_arguments>
|
||||
<message_argument value="op_noexcept"/>
|
||||
</message_arguments>
|
||||
</filter>
|
||||
</resource>
|
||||
<resource path="parser/org/eclipse/cdt/core/dom/ast/IScope.java" type="org.eclipse.cdt.core.dom.ast.IScope$ScopeLookupData">
|
||||
<filter id="1211105284">
|
||||
<message_arguments>
|
||||
|
|
|
@ -119,7 +119,6 @@ public interface IASTUnaryExpression extends IASTExpression {
|
|||
|
||||
/**
|
||||
* For c++, only: noexcept ( expression )
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final int op_noexcept = 17;
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ package org.eclipse.cdt.core.dom.ast.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
|
||||
|
||||
/**
|
||||
* C++ adds a few things to function declarators.
|
||||
|
@ -31,18 +29,8 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
|
|||
*/
|
||||
public static final IASTTypeId[] NO_EXCEPTION_SPECIFICATION = {};
|
||||
|
||||
/**
|
||||
* Represents a 'noexcept' specification without an expression.
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final ICPPASTLiteralExpression NOEXCEPT_DEFAULT =
|
||||
new CPPASTLiteralExpression(ICPPASTLiteralExpression.lk_true, Keywords.cTRUE);
|
||||
|
||||
public static final ASTNodeProperty EXCEPTION_TYPEID = new ASTNodeProperty(
|
||||
"ICPPASTFunctionDeclarator.EXCEPTION_TYPEID [IASTTypeId]"); //$NON-NLS-1$
|
||||
/** @since 5.5 */
|
||||
public static final ASTNodeProperty NOEXCEPT_EXPRESSION = new ASTNodeProperty(
|
||||
"ICPPASTFunctionDeclarator.NOEXCEPT_EXPRESSION [ICPPASTExpression]"); //$NON-NLS-1$
|
||||
/** @since 5.2 */
|
||||
public static final ASTNodeProperty TRAILING_RETURN_TYPE = new ASTNodeProperty(
|
||||
"ICPPASTFunctionDeclarator.TRAILING_RETURN_TYPE [IASTTypeId]"); //$NON-NLS-1$
|
||||
|
@ -115,16 +103,18 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
|
|||
public void setEmptyExceptionSpecification();
|
||||
|
||||
/**
|
||||
* Returns the noexcept expression, {@link #NOEXCEPT_DEFAULT} if the noexcept specification
|
||||
* does not contain an expression, or {@code null} the noexcept specification is not present.
|
||||
* Returns the noexcept expression, {@link
|
||||
* org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator#NOEXCEPT_DEFAULT}
|
||||
* if the noexcept specification does not contain an expression, or {@code null} the noexcept
|
||||
* specification is not present.
|
||||
* See C++11 5.4.1.
|
||||
* @since 5.5
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public ICPPASTExpression getNoexceptExpression();
|
||||
|
||||
/**
|
||||
* Sets the noexcept expression.
|
||||
* @since 5.5
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public void setNoexceptExpression(ICPPASTExpression expression);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
@ -21,8 +22,10 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
@ -32,6 +35,15 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
|||
*/
|
||||
public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPASTFunctionDeclarator,
|
||||
IASTAmbiguityParent {
|
||||
/**
|
||||
* Represents a 'noexcept' specification without an expression.
|
||||
*/
|
||||
public static final ICPPASTLiteralExpression NOEXCEPT_DEFAULT =
|
||||
new CPPASTLiteralExpression(ICPPASTLiteralExpression.lk_true, Keywords.cTRUE);
|
||||
|
||||
public static final ASTNodeProperty NOEXCEPT_EXPRESSION = new ASTNodeProperty(
|
||||
"ICPPASTFunctionDeclarator.NOEXCEPT_EXPRESSION [ICPPASTExpression]"); //$NON-NLS-1$
|
||||
|
||||
private ICPPASTParameterDeclaration[] parameters;
|
||||
private IASTTypeId[] typeIds = NO_EXCEPTION_SPECIFICATION;
|
||||
private ICPPASTExpression noexceptExpression;
|
||||
|
|
|
@ -3964,7 +3964,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
expression = expression();
|
||||
endOffset = consume(IToken.tRPAREN).getEndOffset(); // )
|
||||
} else {
|
||||
expression = ICPPASTFunctionDeclarator.NOEXCEPT_DEFAULT;
|
||||
expression = CPPASTFunctionDeclarator.NOEXCEPT_DEFAULT;
|
||||
}
|
||||
fc.setNoexceptExpression((ICPPASTExpression) expression);
|
||||
}
|
||||
|
|
|
@ -168,6 +168,7 @@ import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
||||
|
@ -1002,7 +1003,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
|
||||
}
|
||||
} else if (node instanceof IASTParameterDeclaration ||
|
||||
node.getPropertyInParent() == ICPPASTFunctionDeclarator.NOEXCEPT_EXPRESSION) {
|
||||
node.getPropertyInParent() == CPPASTFunctionDeclarator.NOEXCEPT_EXPRESSION) {
|
||||
IASTNode parent = node.getParent();
|
||||
if (parent instanceof ICPPASTFunctionDeclarator) {
|
||||
IScope result = scopeViaFunctionDtor((ICPPASTFunctionDeclarator) parent);
|
||||
|
|
|
@ -32,6 +32,7 @@ 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.parser.Keywords;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||
|
||||
/**
|
||||
|
@ -164,7 +165,7 @@ public class DeclaratorWriter extends NodeWriter {
|
|||
if (noexceptExpression != null) {
|
||||
scribe.printSpace();
|
||||
scribe.print(Keywords.NOEXCEPT);
|
||||
if (noexceptExpression != ICPPASTFunctionDeclarator.NOEXCEPT_DEFAULT) {
|
||||
if (noexceptExpression != CPPASTFunctionDeclarator.NOEXCEPT_DEFAULT) {
|
||||
scribe.printSpace();
|
||||
scribe.print('(');
|
||||
noexceptExpression.accept(visitor);
|
||||
|
|
Loading…
Add table
Reference in a new issue