Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2009-12-18 09:58:29 +0000
committerMarkus Schorn2009-12-18 09:58:29 +0000
commit6ad255dfed8ad032c98564bbf729134ad0394fef (patch)
treef2dace8c663740cba1401d962616d9e35cd95602 /core/org.eclipse.cdt.core/parser
parent2a9515f36d66e2d225904de098c33b5e8c25d79e (diff)
downloadorg.eclipse.cdt-6ad255dfed8ad032c98564bbf729134ad0394fef.tar.gz
org.eclipse.cdt-6ad255dfed8ad032c98564bbf729134ad0394fef.tar.xz
org.eclipse.cdt-6ad255dfed8ad032c98564bbf729134ad0394fef.zip
Bug 280909: Syntax and bindings for variadic templates.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java1440
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java32
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArrayDeclarator.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java75
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclarator.java35
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldDeclarator.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPackExpandable.java32
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPackExpansionExpression.java40
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java67
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java74
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeId.java23
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionType.java23
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java38
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameterPackType.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java1
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java1
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclarator.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java115
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java31
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayDeclarator.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java31
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java42
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java86
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java43
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java53
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java74
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeId.java23
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java1
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java35
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java43
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplateSpecialization.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java34
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java27
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java68
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterPackType.java77
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java30
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java560
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java63
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java56
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java93
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java88
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexCPPSignatureUtil.java30
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameter.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateNonTypeParameter.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTypeParameter.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotation.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java84
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java101
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateNonTypeParameter.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTypeParameter.java22
103 files changed, 3038 insertions, 1469 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
index 1689fa073ff..48a37ebcf84 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
@@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
@@ -44,22 +45,22 @@ import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
/**
- * This is a utility class to help convert AST elements to Strings corresponding
- * to the AST element's signature.
+ * This is a utility class to help convert AST elements to Strings corresponding to the AST element's
+ * signature.
*
* @noextend This interface is not intended to be extended by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class ASTSignatureUtil {
-
+
private static final String COMMA_SPACE = ", "; //$NON-NLS-1$
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private static final String SPACE = " "; //$NON-NLS-1$
private static final String[] EMPTY_STRING_ARRAY = new String[0];
-
+
/**
- * Return's the String representation of a node's type (if available). This is
- * currently only being used for testing.
+ * Return's the String representation of a node's type (if available). This is currently only being used
+ * for testing.
*
* TODO Remove this function when done testing if it is no longer needed
*
@@ -67,63 +68,64 @@ public class ASTSignatureUtil {
*/
public static String getNodeSignature(IASTNode node) {
if (node instanceof IASTDeclarator)
- return getSignature((IASTDeclarator)node);
+ return getSignature((IASTDeclarator) node);
if (node instanceof IASTDeclSpecifier)
- return getSignature((IASTDeclSpecifier)node);
+ return getSignature((IASTDeclSpecifier) node);
if (node instanceof IASTTypeId)
- return getSignature((IASTTypeId)node);
- if( node instanceof IASTSimpleDeclaration )
- {
- IASTSimpleDeclaration decl = (IASTSimpleDeclaration) node;
- StringBuffer buffer = new StringBuffer( getSignature( decl.getDeclSpecifier()));
-
- IASTDeclarator [] declarators = decl.getDeclarators();
- for( int i = 0; i < declarators.length; ++i )
- {
- buffer.append( SPACE );
- buffer.append( getSignature( declarators[i] ));
- if( declarators[i].getInitializer() != null && declarators[i].getInitializer() instanceof ICPPASTConstructorInitializer )
- buffer.append( getInitializerString( declarators[i].getInitializer() ));
- }
- buffer.append( ";"); //$NON-NLS-1$
- return buffer.toString();
- }
- if( node instanceof IASTExpression )
- {
- return getExpressionString( (IASTExpression) node );
- }
-
+ return getSignature((IASTTypeId) node);
+ if (node instanceof IASTSimpleDeclaration) {
+ IASTSimpleDeclaration decl = (IASTSimpleDeclaration) node;
+ StringBuffer buffer = new StringBuffer(getSignature(decl.getDeclSpecifier()));
+
+ IASTDeclarator[] declarators = decl.getDeclarators();
+ for (int i = 0; i < declarators.length; ++i) {
+ buffer.append(SPACE);
+ buffer.append(getSignature(declarators[i]));
+ if (declarators[i].getInitializer() != null
+ && declarators[i].getInitializer() instanceof ICPPASTConstructorInitializer)
+ buffer.append(getInitializerString(declarators[i].getInitializer()));
+ }
+ buffer.append(";"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+ if (node instanceof IASTExpression) {
+ return getExpressionString((IASTExpression) node);
+ }
+
return EMPTY_STRING;
}
-
+
/**
* Returns the parameter signature for an IASTDeclarator as a comma separated list wrapped in parenthesis.
*
- * This method uses ASTSignatureUtil#getParametersSignatureArray(IASTArray) to build a comma separated list of the
- * parameter's signatures and then wraps them in parenthesis.
+ * This method uses ASTSignatureUtil#getParametersSignatureArray(IASTArray) to build a comma separated
+ * list of the parameter's signatures and then wraps them in parenthesis.
*
* @param decltor
* @return the parameter signature for an IASTDeclarator as a comma separated list wrapped in parenthesis
*/
- // if only function declarator's have parameters then change this to function declarator... should check before starting.. make my life easier!
+ // if only function declarator's have parameters then change this to function declarator... should check
+ // before starting.. make my life easier!
public static String getParameterSignature(IASTDeclarator decltor) {
// should only be working with decltor that has parms
- if (!(decltor instanceof IASTStandardFunctionDeclarator || decltor instanceof ICASTKnRFunctionDeclarator)) return EMPTY_STRING;
+ if (!(decltor instanceof IASTStandardFunctionDeclarator || decltor instanceof ICASTKnRFunctionDeclarator))
+ return EMPTY_STRING;
StringBuffer result = new StringBuffer();
-
+
String[] parms = getParameterSignatureArray(decltor);
-
+
result.append(Keywords.cpLPAREN);
- for(int i=0; i<parms.length; i++) {
+ for (int i = 0; i < parms.length; i++) {
if (parms[i] != null) {
result.append(parms[i]);
- if (i<parms.length-1) result.append(COMMA_SPACE);
+ if (i < parms.length - 1)
+ result.append(COMMA_SPACE);
}
}
result.append(Keywords.cpRPAREN);
-
- return result.toString();
+
+ return result.toString();
}
/**
@@ -133,227 +135,298 @@ public class ASTSignatureUtil {
* @return a String[] corresponding to the signatures of individual parameters for an IASTDeclarator
*/
public static String[] getParameterSignatureArray(IASTDeclarator decltor) {
-// should only be working with decltor that has parms
- if (!(decltor instanceof IASTStandardFunctionDeclarator || decltor instanceof ICASTKnRFunctionDeclarator)) return EMPTY_STRING_ARRAY;
-
+ // should only be working with decltor that has parms
+ if (!(decltor instanceof IASTStandardFunctionDeclarator || decltor instanceof ICASTKnRFunctionDeclarator))
+ return EMPTY_STRING_ARRAY;
+
String[] result = EMPTY_STRING_ARRAY;
-
+
if (decltor instanceof IASTStandardFunctionDeclarator) {
IASTParameterDeclaration[] parms = null;
- parms = ((IASTStandardFunctionDeclarator)decltor).getParameters();
-
+ parms = ((IASTStandardFunctionDeclarator) decltor).getParameters();
+
if (((IASTStandardFunctionDeclarator) decltor).takesVarArgs()) {
result = new String[parms.length + 1];
result[parms.length] = "..."; //$NON-NLS-1$
- }
- else {
+ } else {
result = new String[parms.length];
}
-
- for(int i=0; i<parms.length; i++) {
+
+ for (int i = 0; i < parms.length; i++) {
if (parms[i] != null) {
result[i] = getSignature(parms[i].getDeclarator());
}
}
} else if (decltor instanceof ICASTKnRFunctionDeclarator) {
IASTName[] names = null;
- names = ((ICASTKnRFunctionDeclarator)decltor).getParameterNames(); // required to get the order the parameters are used
-
+ names = ((ICASTKnRFunctionDeclarator) decltor).getParameterNames(); // required to get the order
+ // the parameters are used
+
result = new String[names.length];
-
- for(int i=0; i<names.length; i++) {
+
+ for (int i = 0; i < names.length; i++) {
if (names[i] != null) {
- final IASTDeclarator declaratorForParameterName = ((ICASTKnRFunctionDeclarator)decltor).getDeclaratorForParameterName(names[i]);
- if( declaratorForParameterName != null )
- result[i] = getSignature(declaratorForParameterName);
+ final IASTDeclarator declaratorForParameterName = ((ICASTKnRFunctionDeclarator) decltor)
+ .getDeclaratorForParameterName(names[i]);
+ if (declaratorForParameterName != null)
+ result[i] = getSignature(declaratorForParameterName);
}
}
}
-
+
return result;
}
-
+
private static String getDeclaratorSpecificSignature(IASTDeclarator declarator) {
StringBuffer result = new StringBuffer();
IASTPointerOperator[] ops = declarator.getPointerOperators();
- boolean needSpace=false;
-
+ boolean needSpace = false;
+
if (ops != null && ops.length > 0) {
- for(int i=0; i<ops.length; i++) {
- if (ops[i] != null) {
- if (needSpace) { result.append(SPACE); }
- if (ops[i] instanceof IASTPointer) {
+ for (IASTPointerOperator op : ops) {
+ if (op != null) {
+ if (needSpace) {
+ result.append(SPACE);
+ }
+ if (op instanceof IASTPointer) {
result.append(Keywords.cpSTAR); // want to have this before keywords on the pointer
- needSpace=true;
+ needSpace = true;
}
-
- if (ops[i] instanceof IGPPASTPointer) {
- if (((IGPPASTPointer)ops[i]).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.RESTRICT); needSpace=true; }
+
+ if (op instanceof IGPPASTPointer) {
+ if (((IGPPASTPointer) op).isRestrict()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.RESTRICT);
+ needSpace = true;
+ }
}
-
- if (ops[i] instanceof ICASTPointer) {
- if (((ICASTPointer)ops[i]).isRestrict()) { 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 (ops[i] instanceof IASTPointer) {
- if (((IASTPointer)ops[i]).isConst()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CONST); needSpace=true; }
- if (((IASTPointer)ops[i]).isVolatile()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VOLATILE); 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) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.VOLATILE);
+ needSpace = true;
+ }
}
-
- if (ops[i] instanceof ICPPASTReferenceOperator) {
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.cpAMPER); needSpace=true;
+
+ if (op instanceof ICPPASTReferenceOperator) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.cpAMPER);
+ needSpace = true;
}
}
}
}
-
+
if (declarator instanceof IASTArrayDeclarator) {
- IASTArrayModifier[] mods = ((IASTArrayDeclarator)declarator).getArrayModifiers();
-
- for(int i=0; i<mods.length; i++) {
- if (mods[i] != null) {
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.cpLBRACKET);
- if (mods[i] instanceof ICASTArrayModifier) {
- if (((ICASTArrayModifier)mods[i]).isConst()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CONST); needSpace=true; }
- if (((ICASTArrayModifier)mods[i]).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.RESTRICT); needSpace=true; }
- if (((ICASTArrayModifier)mods[i]).isStatic()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STATIC); needSpace=true; }
- if (((ICASTArrayModifier)mods[i]).isVolatile()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VOLATILE); }
+ IASTArrayModifier[] mods = ((IASTArrayDeclarator) declarator).getArrayModifiers();
+
+ for (IASTArrayModifier mod : mods) {
+ if (mod != null) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.cpLBRACKET);
+ if (mod instanceof ICASTArrayModifier) {
+ if (((ICASTArrayModifier) mod).isConst()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.CONST);
+ needSpace = true;
+ }
+ if (((ICASTArrayModifier) mod).isRestrict()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.RESTRICT);
+ needSpace = true;
+ }
+ if (((ICASTArrayModifier) mod).isStatic()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.STATIC);
+ needSpace = true;
+ }
+ if (((ICASTArrayModifier) mod).isVolatile()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.VOLATILE);
+ }
}
result.append(Keywords.cpRBRACKET);
}
}
}
-
+
return result.toString();
}
-
+
private static String getDeclaratorSignature(IASTDeclarator declarator) {
- if (declarator == null) return EMPTY_STRING;
-
+ if (declarator == null)
+ return EMPTY_STRING;
+
StringBuffer result = new StringBuffer();
-
+
result.append(getDeclaratorSpecificSignature(declarator));
-
+
if (declarator.getNestedDeclarator() != null) {
result.append(SPACE);
result.append(Keywords.cpLPAREN);
result.append(getDeclaratorSignature(declarator.getNestedDeclarator()));
result.append(Keywords.cpRPAREN);
}
-
+
// append the parameter's signatures
result.append(getParameterSignature(declarator));
-
+
return result.toString();
}
-
+
/**
* This function is used to return the signature of an IASTInitializer.
*
- * TODO this function is used for testing and probably should not public once
- * this Utility class has been finalized as it will likely never be used publicly except for testing
+ * TODO this function is used for testing and probably should not public once this Utility class has been
+ * finalized as it will likely never be used publicly except for testing
*
* @param init
* @return the signature of an IASTInitializer
*/
public static String getInitializerString(IASTInitializer init) {
StringBuffer result = new StringBuffer();
-
- if (init instanceof IASTInitializerExpression){
- result.append(getExpressionString(((IASTInitializerExpression)init).getExpression()));
+
+ if (init instanceof IASTInitializerExpression) {
+ result.append(getExpressionString(((IASTInitializerExpression) init).getExpression()));
} else if (init instanceof IASTInitializerList) {
result.append(Keywords.cpLBRACE);
- IASTInitializer[] inits = ((IASTInitializerList)init).getInitializers();
- for(int i=0; i<inits.length; i++) {
+ IASTInitializer[] inits = ((IASTInitializerList) init).getInitializers();
+ for (int i = 0; i < inits.length; i++) {
result.append(getInitializerString(inits[i]));
- if (i<inits.length-1) result.append(COMMA_SPACE);
+ if (i < inits.length - 1)
+ result.append(COMMA_SPACE);
}
result.append(Keywords.cpRBRACE);
} else if (init instanceof ICASTDesignatedInitializer) {
- ICASTDesignator[] designators = ((ICASTDesignatedInitializer)init).getDesignators();
- for(int i=0; i<designators.length; i++) {
+ ICASTDesignator[] designators = ((ICASTDesignatedInitializer) init).getDesignators();
+ for (int i = 0; i < designators.length; i++) {
result.append(getDesignatorSignature(designators[i]));
- if (i<designators.length-1) result.append(COMMA_SPACE);
+ if (i < designators.length - 1)
+ result.append(COMMA_SPACE);
}
result.append(Keywords.cpASSIGN);
- result.append(getInitializerString(((ICASTDesignatedInitializer)init).getOperandInitializer()));
+ result.append(getInitializerString(((ICASTDesignatedInitializer) init).getOperandInitializer()));
} else if (init instanceof ICPPASTConstructorInitializer) {
- result.append( "("); //$NON-NLS-1$
- result.append( getExpressionString( ((ICPPASTConstructorInitializer)init).getExpression() ));
- result.append( ")"); //$NON-NLS-1$
+ result.append("("); //$NON-NLS-1$
+ result.append(getExpressionString(((ICPPASTConstructorInitializer) init).getExpression()));
+ result.append(")"); //$NON-NLS-1$
}
-
+
return result.toString();
}
-
+
private static String getDesignatorSignature(ICASTDesignator designator) {
StringBuffer result = new StringBuffer();
-
+
if (designator instanceof ICASTArrayDesignator) {
result.append(Keywords.cpLBRACKET);
- result.append(getExpressionString(((ICASTArrayDesignator)designator).getSubscriptExpression()));
+ result.append(getExpressionString(((ICASTArrayDesignator) designator).getSubscriptExpression()));
result.append(Keywords.cpRBRACKET);
} else if (designator instanceof ICASTFieldDesignator) {
result.append(Keywords.cpDOT);
- result.append(((ICASTFieldDesignator)designator).getName().toString());
+ result.append(((ICASTFieldDesignator) designator).getName().toString());
} else if (designator instanceof IGCCASTArrayRangeDesignator) {
result.append(Keywords.cpLBRACKET);
- result.append(getExpressionString(((IGCCASTArrayRangeDesignator)designator).getRangeFloor()));
+ result.append(getExpressionString(((IGCCASTArrayRangeDesignator) designator).getRangeFloor()));
result.append(SPACE);
result.append(Keywords.cpELLIPSIS);
result.append(SPACE);
- result.append(getExpressionString(((IGCCASTArrayRangeDesignator)designator).getRangeCeiling()));
+ result.append(getExpressionString(((IGCCASTArrayRangeDesignator) designator).getRangeCeiling()));
result.append(Keywords.cpRBRACKET);
}
-
+
return result.toString();
}
-
+
/**
- * Returns the String signature corresponding to an IASTDeclarator. This includes the signature
- * of the parameters which is built via ASTSignatureUtil#getParameterSignature(IASTDeclarator)
- * if the declarator is for a function.
+ * Returns the String signature corresponding to an IASTDeclarator. This includes the signature of the
+ * parameters which is built via ASTSignatureUtil#getParameterSignature(IASTDeclarator) if the declarator
+ * is for a function.
*
* @param declarator
* @return the String signature corresponding to an IASTDeclarator
*/
public static String getSignature(IASTDeclarator declarator) {
StringBuffer result = new StringBuffer();
-
+
// get the declSpec
IASTDeclSpecifier declSpec = null;
-
+
IASTNode node = declarator.getParent();
- while( node instanceof IASTDeclarator ){
+ while (node instanceof IASTDeclarator) {
declarator = (IASTDeclarator) node;
node = node.getParent();
}
-
- if( node instanceof IASTParameterDeclaration )
+
+ if (node instanceof IASTParameterDeclaration)
declSpec = ((IASTParameterDeclaration) node).getDeclSpecifier();
- else if( node instanceof IASTSimpleDeclaration )
- declSpec = ((IASTSimpleDeclaration)node).getDeclSpecifier();
- else if( node instanceof IASTFunctionDefinition )
- declSpec = ((IASTFunctionDefinition)node).getDeclSpecifier();
- else if( node instanceof IASTTypeId )
- declSpec = ((IASTTypeId)node).getDeclSpecifier();
-
+ else if (node instanceof IASTSimpleDeclaration)
+ declSpec = ((IASTSimpleDeclaration) node).getDeclSpecifier();
+ else if (node instanceof IASTFunctionDefinition)
+ declSpec = ((IASTFunctionDefinition) node).getDeclSpecifier();
+ else if (node instanceof IASTTypeId)
+ declSpec = ((IASTTypeId) node).getDeclSpecifier();
+
// append the declSpec's signature to the signature
String specString = getSignature(declSpec);
if (specString != null && !specString.equals(EMPTY_STRING))
result.append(specString);
-
+
// append the declarator's signature (without specifier)
String decltorString = getDeclaratorSignature(declarator);
- if (specString != null && specString.length() > 0 &&
- decltorString != null && decltorString.length() > 0) {
+ if (specString != null && specString.length() > 0 && decltorString != null
+ && decltorString.length() > 0) {
result.append(SPACE);
}
result.append(decltorString);
-
+
return result.toString();
}
-
+
/**
* Returns the String representation of the signature for the IASTDeclSpecifier.
*
@@ -361,159 +434,389 @@ public class ASTSignatureUtil {
* @return the String representation of the signature for the IASTDeclSpecifier
*/
public static String getSignature(IASTDeclSpecifier declSpec) {
- if (declSpec == null) return EMPTY_STRING;
- boolean needSpace=false;
-
+ if (declSpec == null)
+ return EMPTY_STRING;
+ boolean needSpace = false;
+
StringBuffer result = new StringBuffer();
-
- if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) { result.append(Keywords.MUTABLE); needSpace=true; }
- if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_auto) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.AUTO); needSpace=true; }
- if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.EXTERN); needSpace=true; }
- if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_register) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.REGISTER); needSpace=true; }
- if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_static) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STATIC); needSpace=true; }
- if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_typedef) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.TYPEDEF); needSpace=true; }
-
- if (declSpec.isConst()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CONST); needSpace=true; }
- if (declSpec.isInline()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.INLINE); needSpace=true; }
- if (declSpec.isVolatile()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VOLATILE); needSpace=true; }
-
- if (declSpec instanceof ICASTDeclSpecifier ) {
- if (((ICASTDeclSpecifier)declSpec).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.RESTRICT); needSpace=true; }
+
+ if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) {
+ result.append(Keywords.MUTABLE);
+ needSpace = true;
+ }
+ if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_auto) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.AUTO);
+ needSpace = true;
+ }
+ if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.EXTERN);
+ needSpace = true;
+ }
+ if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_register) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.REGISTER);
+ needSpace = true;
+ }
+ if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_static) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.STATIC);
+ needSpace = true;
+ }
+ if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.TYPEDEF);
+ needSpace = true;
+ }
+
+ if (declSpec.isConst()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.CONST);
+ needSpace = true;
+ }
+ if (declSpec.isInline()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.INLINE);
+ needSpace = true;
+ }
+ if (declSpec.isVolatile()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.VOLATILE);
+ needSpace = true;
+ }
+
+ if (declSpec instanceof ICASTDeclSpecifier) {
+ if (((ICASTDeclSpecifier) declSpec).isRestrict()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.RESTRICT);
+ needSpace = true;
+ }
} else if (declSpec instanceof ICPPASTDeclSpecifier) {
- if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.MUTABLE); needSpace=true; }
- if (((ICPPASTDeclSpecifier)declSpec).isExplicit()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.EXPLICIT); needSpace=true; }
- if (((ICPPASTDeclSpecifier)declSpec).isFriend()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.FRIEND); needSpace=true; }
- if (((ICPPASTDeclSpecifier)declSpec).isVirtual()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VIRTUAL); needSpace=true; }
+ if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.MUTABLE);
+ needSpace = true;
+ }
+ if (((ICPPASTDeclSpecifier) declSpec).isExplicit()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.EXPLICIT);
+ needSpace = true;
+ }
+ if (((ICPPASTDeclSpecifier) declSpec).isFriend()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.FRIEND);
+ needSpace = true;
+ }
+ if (((ICPPASTDeclSpecifier) declSpec).isVirtual()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.VIRTUAL);
+ needSpace = true;
+ }
} else if (declSpec instanceof IGPPASTDeclSpecifier) {
- if (((IGPPASTDeclSpecifier)declSpec).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.RESTRICT); needSpace=true; }
+ if (((IGPPASTDeclSpecifier) declSpec).isRestrict()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.RESTRICT);
+ needSpace = true;
+ }
}
-
- // handle complex cases
+
+ // handle complex cases
if (declSpec instanceof IASTCompositeTypeSpecifier) {
// 101114 fix, do not display class, and for consistency don't display struct/union as well
-// if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
-// switch(((ICPPASTCompositeTypeSpecifier)declSpec).getKey()) {
-// case ICPPASTCompositeTypeSpecifier.k_class:
-// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS); needSpace=true;
-// break;
-// case IASTCompositeTypeSpecifier.k_struct:
-// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
-// break;
-// case IASTCompositeTypeSpecifier.k_union:
-// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
-// break;
-// }
-// } else if (declSpec instanceof ICASTCompositeTypeSpecifier) {
-// switch(((ICASTCompositeTypeSpecifier)declSpec).getKey()) {
-// case IASTCompositeTypeSpecifier.k_struct:
-// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
-// break;
-// case IASTCompositeTypeSpecifier.k_union:
-// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
-// break;
-// }
-// }
-
- result.append(((IASTCompositeTypeSpecifier)declSpec).getName());
+ // if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
+ // switch(((ICPPASTCompositeTypeSpecifier)declSpec).getKey()) {
+ // case ICPPASTCompositeTypeSpecifier.k_class:
+ // if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS);
+ // needSpace=true;
+ // break;
+ // case IASTCompositeTypeSpecifier.k_struct:
+ // if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT);
+ // needSpace=true;
+ // break;
+ // case IASTCompositeTypeSpecifier.k_union:
+ // if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION);
+ // needSpace=true;
+ // break;
+ // }
+ // } else if (declSpec instanceof ICASTCompositeTypeSpecifier) {
+ // switch(((ICASTCompositeTypeSpecifier)declSpec).getKey()) {
+ // case IASTCompositeTypeSpecifier.k_struct:
+ // if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT);
+ // needSpace=true;
+ // break;
+ // case IASTCompositeTypeSpecifier.k_union:
+ // if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION);
+ // needSpace=true;
+ // break;
+ // }
+ // }
+
+ result.append(((IASTCompositeTypeSpecifier) declSpec).getName());
} else if (declSpec instanceof IASTElaboratedTypeSpecifier) {
-// 101114 fix, do not display class, and for consistency don't display struct/union as well
-// switch(((IASTElaboratedTypeSpecifier)declSpec).getKind()) {
-// case ICPPASTElaboratedTypeSpecifier.k_class:
-// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS); needSpace=true;
-// break;
-// case IASTElaboratedTypeSpecifier.k_enum:
-// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.ENUM); needSpace=true;
-// break;
-// case IASTElaboratedTypeSpecifier.k_struct:
-// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
-// break;
-// case IASTElaboratedTypeSpecifier.k_union:
-// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
-// break;
-// }
- result.append(((IASTElaboratedTypeSpecifier)declSpec).getName());
+ // 101114 fix, do not display class, and for consistency don't display struct/union as well
+ // switch(((IASTElaboratedTypeSpecifier)declSpec).getKind()) {
+ // case ICPPASTElaboratedTypeSpecifier.k_class:
+ // if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS);
+ // needSpace=true;
+ // break;
+ // case IASTElaboratedTypeSpecifier.k_enum:
+ // if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.ENUM);
+ // needSpace=true;
+ // break;
+ // case IASTElaboratedTypeSpecifier.k_struct:
+ // if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT);
+ // needSpace=true;
+ // break;
+ // case IASTElaboratedTypeSpecifier.k_union:
+ // if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION);
+ // needSpace=true;
+ // break;
+ // }
+ result.append(((IASTElaboratedTypeSpecifier) declSpec).getName());
} else if (declSpec instanceof IASTEnumerationSpecifier) {
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.ENUM); needSpace=true;
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.ENUM);
+ needSpace = true;
} else if (declSpec instanceof IASTNamedTypeSpecifier) {
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(((IASTNamedTypeSpecifier)declSpec).getName().toString()); needSpace=true;
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(((IASTNamedTypeSpecifier) declSpec).getName().toString());
+ needSpace = true;
} else if (declSpec instanceof IASTSimpleDeclSpecifier) {
// handle complex cases
if (declSpec instanceof IGPPASTSimpleDeclSpecifier) {
- if (((IGPPASTSimpleDeclSpecifier)declSpec).isLongLong()) result.append(Keywords.LONG_LONG);
- if (((IGPPASTSimpleDeclSpecifier)declSpec).isComplex()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_COMPLEX); needSpace=true; }
- if (((IGPPASTSimpleDeclSpecifier)declSpec).isImaginary()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_IMAGINARY); needSpace=true; }
-
- switch(((IGPPASTSimpleDeclSpecifier)declSpec).getType()) {
- case IGPPASTSimpleDeclSpecifier.t_typeof:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(GCCKeywords.TYPEOF); needSpace=true;
- break;
+ if (((IGPPASTSimpleDeclSpecifier) declSpec).isLongLong())
+ result.append(Keywords.LONG_LONG);
+ if (((IGPPASTSimpleDeclSpecifier) declSpec).isComplex()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.c_COMPLEX);
+ needSpace = true;
+ }
+ if (((IGPPASTSimpleDeclSpecifier) declSpec).isImaginary()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.c_IMAGINARY);
+ needSpace = true;
+ }
+
+ switch (((IGPPASTSimpleDeclSpecifier) declSpec).getType()) {
+ case IGPPASTSimpleDeclSpecifier.t_typeof:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(GCCKeywords.TYPEOF);
+ needSpace = true;
+ break;
}
}
-
+
if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
- switch(((ICPPASTSimpleDeclSpecifier)declSpec).getType()) {
- case ICPPASTSimpleDeclSpecifier.t_bool:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.BOOL); needSpace=true;
- break;
- case ICPPASTSimpleDeclSpecifier.t_wchar_t:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.WCHAR_T); needSpace=true;
- break;
+ switch (((ICPPASTSimpleDeclSpecifier) declSpec).getType()) {
+ case ICPPASTSimpleDeclSpecifier.t_bool:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.BOOL);
+ needSpace = true;
+ break;
+ case ICPPASTSimpleDeclSpecifier.t_wchar_t:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.WCHAR_T);
+ needSpace = true;
+ break;
}
}
-
+
if (declSpec instanceof ICASTSimpleDeclSpecifier) {
- if (((ICASTSimpleDeclSpecifier)declSpec).isLongLong()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.LONG_LONG); needSpace=true; }
- if (((ICASTSimpleDeclSpecifier)declSpec).isComplex()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_COMPLEX); needSpace=true; }
- if (((ICASTSimpleDeclSpecifier)declSpec).isImaginary()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_IMAGINARY); needSpace=true; }
-
- switch(((ICASTSimpleDeclSpecifier)declSpec).getType()) {
- case ICASTSimpleDeclSpecifier.t_Bool:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_BOOL); needSpace=true;
- break;
+ if (((ICASTSimpleDeclSpecifier) declSpec).isLongLong()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.LONG_LONG);
+ needSpace = true;
+ }
+ if (((ICASTSimpleDeclSpecifier) declSpec).isComplex()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.c_COMPLEX);
+ needSpace = true;
+ }
+ if (((ICASTSimpleDeclSpecifier) declSpec).isImaginary()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.c_IMAGINARY);
+ needSpace = true;
+ }
+
+ switch (((ICASTSimpleDeclSpecifier) declSpec).getType()) {
+ case ICASTSimpleDeclSpecifier.t_Bool:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.c_BOOL);
+ needSpace = true;
+ break;
}
}
-
-
+
// handle simple cases
- if (((IASTSimpleDeclSpecifier)declSpec).isLong()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.LONG); needSpace=true; }
- if (((IASTSimpleDeclSpecifier)declSpec).isShort()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.SHORT); needSpace=true; }
- if (((IASTSimpleDeclSpecifier)declSpec).isSigned()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.SIGNED); needSpace=true; }
- if (((IASTSimpleDeclSpecifier)declSpec).isUnsigned()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNSIGNED); needSpace=true; }
-
- switch(((IASTSimpleDeclSpecifier)declSpec).getType()) {
- case IASTSimpleDeclSpecifier.t_char:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CHAR); needSpace=true;
- break;
- case IASTSimpleDeclSpecifier.t_double:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.DOUBLE); needSpace=true;
- break;
- case IASTSimpleDeclSpecifier.t_float:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.FLOAT); needSpace=true;
- break;
- case IASTSimpleDeclSpecifier.t_int:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.INT); needSpace=true;
- break;
- case IASTSimpleDeclSpecifier.t_void:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VOID); needSpace=true;
- break;
+ if (((IASTSimpleDeclSpecifier) declSpec).isLong()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.LONG);
+ needSpace = true;
+ }
+ if (((IASTSimpleDeclSpecifier) declSpec).isShort()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.SHORT);
+ needSpace = true;
+ }
+ if (((IASTSimpleDeclSpecifier) declSpec).isSigned()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.SIGNED);
+ needSpace = true;
+ }
+ if (((IASTSimpleDeclSpecifier) declSpec).isUnsigned()) {
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.UNSIGNED);
+ needSpace = true;
+ }
+
+ switch (((IASTSimpleDeclSpecifier) declSpec).getType()) {
+ case IASTSimpleDeclSpecifier.t_char:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.CHAR);
+ needSpace = true;
+ break;
+ case IASTSimpleDeclSpecifier.t_double:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.DOUBLE);
+ needSpace = true;
+ break;
+ case IASTSimpleDeclSpecifier.t_float:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.FLOAT);
+ needSpace = true;
+ break;
+ case IASTSimpleDeclSpecifier.t_int:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.INT);
+ needSpace = true;
+ break;
+ case IASTSimpleDeclSpecifier.t_void:
+ if (needSpace) {
+ result.append(SPACE);
+ needSpace = false;
+ }
+ result.append(Keywords.VOID);
+ needSpace = true;
+ break;
}
}
-
+
return result.toString();
}
-
+
/**
* Returns the String representation of the signature for the IASTTypeId.
+ *
* @param typeId
* @return the String representation of the signature for the IASTTypeId
*/
public static String getSignature(IASTTypeId typeId) {
return getSignature(typeId.getAbstractDeclarator());
}
-
+
/**
- * Return a string representation for the given IASTExpression. Expressions having an extension kind should
- * provide their own toString method which will be called by this.
+ * Return a string representation for the given IASTExpression. Expressions having an extension kind
+ * should provide their own toString method which will be called by this.
*
* @param expression
* @return a string representation for the given IASTExpression
@@ -553,10 +856,12 @@ public class ASTSignatureUtil {
return getTypenameExpression((ICPPASTTypenameExpression)expression);
else if (expression instanceof IGNUASTCompoundStatementExpression)
return getCompoundStatementExpression((IGNUASTCompoundStatementExpression)expression);
+ else if (expression instanceof ICPPASTPackExpansionExpression)
+ return getPackExpansionExpression((ICPPASTPackExpansionExpression) expression);
return getEmptyExpression( expression );
}
-
+
private static String getArraySubscriptExpression(IASTArraySubscriptExpression expression) {
StringBuffer result = new StringBuffer();
result.append(getExpressionString(expression.getArrayExpression()));
@@ -565,14 +870,14 @@ public class ASTSignatureUtil {
result.append(Keywords.cpRBRACKET);
return result.toString();
}
-
+
private static String getCastExpression(IASTCastExpression expression) {
StringBuffer result = new StringBuffer();
boolean normalCast = false;
-
+
if (expression.getOperator() == IASTCastExpression.op_cast)
normalCast = true;
-
+
if (normalCast) {
result.append(Keywords.cpLPAREN);
result.append(getSignature(expression.getTypeId()));
@@ -587,10 +892,10 @@ public class ASTSignatureUtil {
result.append(getExpressionString(expression.getOperand()));
result.append(Keywords.cpRPAREN);
}
-
+
return result.toString();
}
-
+
private static String getFieldReference(IASTFieldReference expression) {
StringBuffer result = new StringBuffer();
result.append(getExpressionString(expression.getFieldOwner()));
@@ -598,11 +903,11 @@ public class ASTSignatureUtil {
result.append(Keywords.cpARROW);
else
result.append(Keywords.cpDOT);
-
+
result.append(expression.getFieldName().toString());
return result.toString();
}
-
+
private static String getFunctionCallExpression(IASTFunctionCallExpression expression) {
StringBuffer result = new StringBuffer();
result.append(getExpressionString(expression.getFunctionNameExpression()));
@@ -611,7 +916,7 @@ public class ASTSignatureUtil {
result.append(Keywords.cpRPAREN);
return result.toString();
}
-
+
private static String getTypeIdInitializerExpression(ICASTTypeIdInitializerExpression expression) {
StringBuffer result = new StringBuffer();
result.append(Keywords.cpLPAREN);
@@ -620,7 +925,7 @@ public class ASTSignatureUtil {
result.append(getInitializerString(expression.getInitializer()));
return result.toString();
}
-
+
private static String getDeleteExpression(ICPPASTDeleteExpression expression) {
StringBuffer result = new StringBuffer();
result.append(Keywords.DELETE);
@@ -629,50 +934,50 @@ public class ASTSignatureUtil {
result.append(getExpressionString(expression.getOperand()));
return result.toString();
}
-
+
private static String getSimpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression expression) {
StringBuffer result = new StringBuffer();
switch (expression.getSimpleType()) {
- case ICPPASTSimpleTypeConstructorExpression.t_bool:
- result.append(Keywords.BOOL);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_char:
- result.append(Keywords.CHAR);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_double:
- result.append(Keywords.DOUBLE);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_float:
- result.append(Keywords.FLOAT);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_int:
- result.append(Keywords.INT);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_long:
- result.append(Keywords.LONG);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_short:
- result.append(Keywords.SHORT);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_signed:
- result.append(Keywords.SIGNED);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_unsigned:
- result.append(Keywords.UNSIGNED);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_void:
- result.append(Keywords.VOID);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_wchar_t:
- result.append(Keywords.WCHAR_T);
- break;
+ case ICPPASTSimpleTypeConstructorExpression.t_bool:
+ result.append(Keywords.BOOL);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_char:
+ result.append(Keywords.CHAR);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_double:
+ result.append(Keywords.DOUBLE);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_float:
+ result.append(Keywords.FLOAT);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_int:
+ result.append(Keywords.INT);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_long:
+ result.append(Keywords.LONG);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_short:
+ result.append(Keywords.SHORT);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_signed:
+ result.append(Keywords.SIGNED);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_unsigned:
+ result.append(Keywords.UNSIGNED);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_void:
+ result.append(Keywords.VOID);
+ break;
+ case ICPPASTSimpleTypeConstructorExpression.t_wchar_t:
+ result.append(Keywords.WCHAR_T);
+ break;
}
result.append(Keywords.cpLPAREN);
result.append(expression.getInitialValue());
result.append(Keywords.cpRPAREN);
return result.toString();
}
-
+
private static String getTypenameExpression(ICPPASTTypenameExpression expression) {
StringBuffer result = new StringBuffer();
result.append(Keywords.TYPENAME);
@@ -686,48 +991,55 @@ public class ASTSignatureUtil {
result.append(Keywords.cpRPAREN);
return result.toString();
}
-
+
private static String getCompoundStatementExpression(IGNUASTCompoundStatementExpression expression) {
- return String.valueOf(Keywords.cpELLIPSIS); // TODO might need to getSignature(IASTStatement) in the future
+ return String.valueOf(Keywords.cpELLIPSIS); // TODO might need to getSignature(IASTStatement) in the
+ // future
}
-
+
private static String getTypeIdExpression(IASTTypeIdExpression expression) {
StringBuffer result = new StringBuffer();
- String operator = getTypeIdExpressionOperator(expression);
- if (operator != null && !operator.equals(EMPTY_STRING)) result.append(operator);
-
- if (operator != null && !operator.equals(EMPTY_STRING)) { result.append(SPACE); result.append(Keywords.cpLPAREN); }
+ String operator = getTypeIdExpressionOperator(expression);
+ if (operator != null && !operator.equals(EMPTY_STRING))
+ result.append(operator);
+
+ if (operator != null && !operator.equals(EMPTY_STRING)) {
+ result.append(SPACE);
+ result.append(Keywords.cpLPAREN);
+ }
result.append(getSignature(expression.getTypeId()));
- if (operator != null && !operator.equals(EMPTY_STRING)) result.append(Keywords.cpRPAREN);
+ if (operator != null && !operator.equals(EMPTY_STRING))
+ result.append(Keywords.cpRPAREN);
return result.toString();
}
-
+
private static String getExpressionList(IASTExpressionList expression) {
StringBuffer result = new StringBuffer();
IASTExpression[] exps = expression.getExpressions();
- if (exps != null && exps.length>0) {
- for(int i=0; i<exps.length; i++) {
+ if (exps != null && exps.length > 0) {
+ for (int i = 0; i < exps.length; i++) {
result.append(getExpressionString(exps[i]));
- if (i < exps.length-1) {
+ if (i < exps.length - 1) {
result.append(COMMA_SPACE);
}
}
}
return result.toString();
}
-
- private static String getEmptyExpression( IASTExpression expression ){
+
+ private static String getEmptyExpression(IASTExpression expression) {
return EMPTY_STRING;
}
-
- private static String getLiteralExpression( IASTLiteralExpression expression ){
+
+ private static String getLiteralExpression(IASTLiteralExpression expression) {
return expression.toString();
}
-
- private static String getIdExpression( IASTIdExpression expression ){
+
+ private static String getIdExpression(IASTIdExpression expression) {
return expression.getName().toString();
}
- private static String getConditionalExpression( IASTConditionalExpression expression ){
+
+ private static String getConditionalExpression(IASTConditionalExpression expression) {
StringBuffer result = new StringBuffer();
result.append(getExpressionString(expression.getLogicalConditionExpression()));
result.append(SPACE);
@@ -743,7 +1055,8 @@ public class ASTSignatureUtil {
result.append(getExpressionString(expression.getNegativeResultExpression()));
return result.toString();
}
- private static String getNewExpression( ICPPASTNewExpression expression ){
+
+ private static String getNewExpression(ICPPASTNewExpression expression) {
StringBuffer result = new StringBuffer();
result.append(Keywords.NEW);
result.append(SPACE);
@@ -756,50 +1069,55 @@ public class ASTSignatureUtil {
result.append(Keywords.cpRPAREN);
return result.toString();
}
- private static String getBinaryExpression( IASTBinaryExpression expression ){
+
+ private static String getBinaryExpression(IASTBinaryExpression expression) {
StringBuffer buffer = new StringBuffer();
- buffer.append( getExpressionString( expression.getOperand1() ) );
+ buffer.append(getExpressionString(expression.getOperand1()));
buffer.append(SPACE);
- buffer.append( getBinaryOperatorString( expression ));
+ buffer.append(getBinaryOperatorString(expression));
buffer.append(SPACE);
- buffer.append( getExpressionString( expression.getOperand2() ) );
+ buffer.append(getExpressionString(expression.getOperand2()));
return buffer.toString();
}
- private static String getUnaryExpression( IASTUnaryExpression expression ){
+ private static String getUnaryExpression(IASTUnaryExpression expression) {
StringBuffer buffer = new StringBuffer();
- boolean postOperator=false;
- boolean primaryBracketed=false;
-
- switch(expression.getOperator()) {
- case IASTUnaryExpression.op_postFixDecr:
- case IASTUnaryExpression.op_postFixIncr:
- postOperator=true;
- break;
- case IASTUnaryExpression.op_bracketedPrimary:
- primaryBracketed=true;
- break;
- default:
- postOperator=false;
- break;
+ boolean postOperator = false;
+ boolean primaryBracketed = false;
+
+ switch (expression.getOperator()) {
+ case IASTUnaryExpression.op_postFixDecr:
+ case IASTUnaryExpression.op_postFixIncr:
+ postOperator = true;
+ break;
+ case IASTUnaryExpression.op_bracketedPrimary:
+ primaryBracketed = true;
+ break;
+ default:
+ postOperator = false;
+ break;
}
-
- if (!postOperator && !primaryBracketed) buffer.append(getUnaryOperatorString(expression));
-
+
+ if (!postOperator && !primaryBracketed)
+ buffer.append(getUnaryOperatorString(expression));
+
// need to add a space to the unary expression if it is a specific operator
- switch(expression.getOperator()) {
- case IASTUnaryExpression.op_sizeof:
- case ICPPASTUnaryExpression.op_throw:
- case ICPPASTUnaryExpression.op_typeid:
- buffer.append(SPACE);
- break;
+ switch (expression.getOperator()) {
+ case IASTUnaryExpression.op_sizeof:
+ case ICPPASTUnaryExpression.op_throw:
+ case ICPPASTUnaryExpression.op_typeid:
+ buffer.append(SPACE);
+ break;
}
-
- if (primaryBracketed) buffer.append(Keywords.cpLPAREN);
+
+ if (primaryBracketed)
+ buffer.append(Keywords.cpLPAREN);
buffer.append(getExpressionString(expression.getOperand()));
- if (primaryBracketed) buffer.append(Keywords.cpRPAREN);
- if (postOperator && !primaryBracketed) buffer.append(getUnaryOperatorString(expression));
-
+ if (primaryBracketed)
+ buffer.append(Keywords.cpRPAREN);
+ if (postOperator && !primaryBracketed)
+ buffer.append(getUnaryOperatorString(expression));
+
return buffer.toString();
}
@@ -812,37 +1130,38 @@ public class ASTSignatureUtil {
public static String getCastOperatorString(IASTCastExpression expression) {
int op = expression.getOperator();
String opString = EMPTY_STRING;
-
+
if (expression instanceof ICPPASTCastExpression) {
switch (op) {
- case ICPPASTCastExpression.op_const_cast:
- opString = Keywords.CONST_CAST;
- break;
- case ICPPASTCastExpression.op_dynamic_cast:
- opString = Keywords.DYNAMIC_CAST;
- break;
- case ICPPASTCastExpression.op_reinterpret_cast:
- opString = Keywords.REINTERPRET_CAST;
- break;
- case ICPPASTCastExpression.op_static_cast:
- opString = Keywords.STATIC_CAST;
- break;
- default:
- break;
+ case ICPPASTCastExpression.op_const_cast:
+ opString = Keywords.CONST_CAST;
+ break;
+ case ICPPASTCastExpression.op_dynamic_cast:
+ opString = Keywords.DYNAMIC_CAST;
+ break;
+ case ICPPASTCastExpression.op_reinterpret_cast:
+ opString = Keywords.REINTERPRET_CAST;
+ break;
+ case ICPPASTCastExpression.op_static_cast:
+ opString = Keywords.STATIC_CAST;
+ break;
+ default:
+ break;
}
}
-
- if (!opString.equals(EMPTY_STRING)) return opString;
-
- switch(op) {
- case IASTCastExpression.op_cast:
- opString = Keywords.CAST;
- break;
+
+ if (!opString.equals(EMPTY_STRING))
+ return opString;
+
+ switch (op) {
+ case IASTCastExpression.op_cast:
+ opString = Keywords.CAST;
+ break;
}
-
+
return opString;
}
-
+
/**
* Returns the String representation of the IASTUnaryExpression's operator.
*
@@ -852,68 +1171,72 @@ public class ASTSignatureUtil {
public static String getUnaryOperatorString(IASTUnaryExpression ue) {
int op = ue.getOperator();
String opString = EMPTY_STRING;
-
+
if (ue instanceof ICPPASTUnaryExpression) {
- switch(op) {
- case ICPPASTUnaryExpression.op_throw:
- opString = Keywords.THROW;
- break;
- case ICPPASTUnaryExpression.op_typeid:
- opString = Keywords.TYPEID;
- break;
- }
- } else if (ue instanceof IGNUASTUnaryExpression) {
- switch(op) {
- case IGNUASTUnaryExpression.op_alignOf:
- opString = Keywords.ALIGNOF;
- break;
- case IGNUASTUnaryExpression.op_typeof:
- opString = Keywords.TYPEOF;
- break;
- }
- }
-
- if (!opString.equals(EMPTY_STRING)) return opString;
-
- switch(op) {
- case IASTUnaryExpression.op_amper:
- opString = String.valueOf(Keywords.cpAMPER);
- break;
- case IASTUnaryExpression.op_minus:
- opString = String.valueOf(Keywords.cpMINUS);
- break;
- case IASTUnaryExpression.op_not:
- opString = String.valueOf(Keywords.cpNOT);
- break;
- case IASTUnaryExpression.op_plus:
- opString = String.valueOf(Keywords.cpPLUS);
- break;
- case IASTUnaryExpression.op_postFixDecr:
- opString = String.valueOf(Keywords.cpDECR);
- break;
- case IASTUnaryExpression.op_postFixIncr:
- opString = String.valueOf(Keywords.cpINCR);
- break;
- case IASTUnaryExpression.op_prefixDecr:
- opString = String.valueOf(Keywords.cpDECR);
- break;
- case IASTUnaryExpression.op_prefixIncr:
- opString = String.valueOf(Keywords.cpINCR);
+ switch (op) {
+ case ICPPASTUnaryExpression.op_throw:
+ opString = Keywords.THROW;
break;
- case IASTUnaryExpression.op_sizeof:
- opString = Keywords.SIZEOF;
+ case ICPPASTUnaryExpression.op_typeid:
+ opString = Keywords.TYPEID;
break;
- case IASTUnaryExpression.op_star:
- opString = String.valueOf(Keywords.cpSTAR);
+ }
+ } else if (ue instanceof IGNUASTUnaryExpression) {
+ switch (op) {
+ case IGNUASTUnaryExpression.op_alignOf:
+ opString = Keywords.ALIGNOF;
break;
- case IASTUnaryExpression.op_tilde:
- opString = String.valueOf(Keywords.cpCOMPL);
+ case IGNUASTUnaryExpression.op_typeof:
+ opString = Keywords.TYPEOF;
break;
+ }
}
-
+
+ if (!opString.equals(EMPTY_STRING))
+ return opString;
+
+ switch (op) {
+ case IASTUnaryExpression.op_amper:
+ opString = String.valueOf(Keywords.cpAMPER);
+ break;
+ case IASTUnaryExpression.op_minus:
+ opString = String.valueOf(Keywords.cpMINUS);
+ break;
+ case IASTUnaryExpression.op_not:
+ opString = String.valueOf(Keywords.cpNOT);
+ break;
+ case IASTUnaryExpression.op_plus:
+ opString = String.valueOf(Keywords.cpPLUS);
+ break;
+ case IASTUnaryExpression.op_postFixDecr:
+ opString = String.valueOf(Keywords.cpDECR);
+ break;
+ case IASTUnaryExpression.op_postFixIncr:
+ opString = String.valueOf(Keywords.cpINCR);
+ break;
+ case IASTUnaryExpression.op_prefixDecr:
+ opString = String.valueOf(Keywords.cpDECR);
+ break;
+ case IASTUnaryExpression.op_prefixIncr:
+ opString = String.valueOf(Keywords.cpINCR);
+ break;
+ case IASTUnaryExpression.op_sizeof:
+ opString = Keywords.SIZEOF;
+ break;
+ case IASTUnaryExpression.op_sizeofParameterPack:
+ opString = Keywords.SIZEOF + new String(Keywords.cpELLIPSIS);
+ break;
+ case IASTUnaryExpression.op_star:
+ opString = String.valueOf(Keywords.cpSTAR);
+ break;
+ case IASTUnaryExpression.op_tilde:
+ opString = String.valueOf(Keywords.cpCOMPL);
+ break;
+ }
+
return opString;
}
-
+
/**
* Returns the String representation of the IASTBinaryExpression's operator.
*
@@ -923,111 +1246,111 @@ public class ASTSignatureUtil {
public static String getBinaryOperatorString(IASTBinaryExpression be) {
int op = be.getOperator();
String opString = EMPTY_STRING;
- switch(op) {
- case IASTBinaryExpression.op_multiply:
- opString = String.valueOf(Keywords.cpSTAR);
- break;
- case IASTBinaryExpression.op_divide:
- opString = String.valueOf(Keywords.cpDIV);
- break;
- case IASTBinaryExpression.op_modulo:
- opString = String.valueOf(Keywords.cpMOD);
- break;
- case IASTBinaryExpression.op_plus:
- opString = String.valueOf(Keywords.cpPLUS);
- break;
- case IASTBinaryExpression.op_minus:
- opString = String.valueOf(Keywords.cpMINUS);
- break;
- case IASTBinaryExpression.op_shiftLeft:
- opString = String.valueOf(Keywords.cpSHIFTL);
- break;
- case IASTBinaryExpression.op_shiftRight:
- opString = String.valueOf(Keywords.cpSHIFTR);
- break;
- case IASTBinaryExpression.op_lessThan:
- opString = String.valueOf(Keywords.cpLT);
- break;
- case IASTBinaryExpression.op_greaterThan:
- opString = String.valueOf(Keywords.cpGT);
- break;
- case IASTBinaryExpression.op_lessEqual:
- opString = String.valueOf(Keywords.cpLTEQUAL);
- break;
- case IASTBinaryExpression.op_greaterEqual:
- opString = String.valueOf(Keywords.cpGTEQUAL);
- break;
- case IASTBinaryExpression.op_binaryAnd:
- opString = String.valueOf(Keywords.cpAMPER);
- break;
- case IASTBinaryExpression.op_binaryXor:
- opString = String.valueOf(Keywords.cpXOR);
- break;
- case IASTBinaryExpression.op_binaryOr:
- opString = String.valueOf(Keywords.cpBITOR);
- break;
- case IASTBinaryExpression.op_logicalAnd:
- opString = String.valueOf(Keywords.cpAND);
- break;
- case IASTBinaryExpression.op_logicalOr:
- opString = String.valueOf(Keywords.cpOR);
- break;
- case IASTBinaryExpression.op_assign:
- opString = String.valueOf(Keywords.cpASSIGN);
- break;
- case IASTBinaryExpression.op_multiplyAssign:
- opString = String.valueOf(Keywords.cpSTARASSIGN);
- break;
- case IASTBinaryExpression.op_divideAssign:
- opString = String.valueOf(Keywords.cpDIVASSIGN);
- break;
- case IASTBinaryExpression.op_moduloAssign:
- opString = String.valueOf(Keywords.cpMODASSIGN);
- break;
- case IASTBinaryExpression.op_plusAssign:
- opString = String.valueOf(Keywords.cpPLUSASSIGN);
- break;
- case IASTBinaryExpression.op_minusAssign:
- opString = String.valueOf(Keywords.cpMINUSASSIGN);
- break;
- case IASTBinaryExpression.op_shiftLeftAssign:
- opString = String.valueOf(Keywords.cpSHIFTLASSIGN);
- break;
- case IASTBinaryExpression.op_shiftRightAssign:
- opString = String.valueOf(Keywords.cpSHIFTRASSIGN);
- break;
- case IASTBinaryExpression.op_binaryAndAssign:
- opString = String.valueOf(Keywords.cpAMPERASSIGN);
- break;
- case IASTBinaryExpression.op_binaryXorAssign:
- opString = String.valueOf(Keywords.cpXORASSIGN);
- break;
- case IASTBinaryExpression.op_binaryOrAssign:
- opString = String.valueOf(Keywords.cpBITORASSIGN);
- break;
- case IASTBinaryExpression.op_equals:
- opString = String.valueOf(Keywords.cpEQUAL);
- break;
- case IASTBinaryExpression.op_notequals:
- opString = String.valueOf(Keywords.cpNOTEQUAL);
- break;
- case IASTBinaryExpression.op_max:
- opString = String.valueOf(Keywords.cpMAX);
- break;
- case IASTBinaryExpression.op_min:
- opString = String.valueOf(Keywords.cpMIN);
- break;
- case IASTBinaryExpression.op_pmarrow:
- opString = String.valueOf(Keywords.cpARROW);
- break;
- case IASTBinaryExpression.op_pmdot:
- opString = String.valueOf(Keywords.cpDOT);
- break;
+ switch (op) {
+ case IASTBinaryExpression.op_multiply:
+ opString = String.valueOf(Keywords.cpSTAR);
+ break;
+ case IASTBinaryExpression.op_divide:
+ opString = String.valueOf(Keywords.cpDIV);
+ break;
+ case IASTBinaryExpression.op_modulo:
+ opString = String.valueOf(Keywords.cpMOD);
+ break;
+ case IASTBinaryExpression.op_plus:
+ opString = String.valueOf(Keywords.cpPLUS);
+ break;
+ case IASTBinaryExpression.op_minus:
+ opString = String.valueOf(Keywords.cpMINUS);
+ break;
+ case IASTBinaryExpression.op_shiftLeft:
+ opString = String.valueOf(Keywords.cpSHIFTL);
+ break;
+ case IASTBinaryExpression.op_shiftRight:
+ opString = String.valueOf(Keywords.cpSHIFTR);
+ break;
+ case IASTBinaryExpression.op_lessThan:
+ opString = String.valueOf(Keywords.cpLT);
+ break;
+ case IASTBinaryExpression.op_greaterThan:
+ opString = String.valueOf(Keywords.cpGT);
+ break;
+ case IASTBinaryExpression.op_lessEqual:
+ opString = String.valueOf(Keywords.cpLTEQUAL);
+ break;
+ case IASTBinaryExpression.op_greaterEqual:
+ opString = String.valueOf(Keywords.cpGTEQUAL);
+ break;
+ case IASTBinaryExpression.op_binaryAnd:
+ opString = String.valueOf(Keywords.cpAMPER);
+ break;
+ case IASTBinaryExpression.op_binaryXor:
+ opString = String.valueOf(Keywords.cpXOR);
+ break;
+ case IASTBinaryExpression.op_binaryOr:
+ opString = String.valueOf(Keywords.cpBITOR);
+ break;
+ case IASTBinaryExpression.op_logicalAnd:
+ opString = String.valueOf(Keywords.cpAND);
+ break;
+ case IASTBinaryExpression.op_logicalOr:
+ opString = String.valueOf(Keywords.cpOR);
+ break;
+ case IASTBinaryExpression.op_assign:
+ opString = String.valueOf(Keywords.cpASSIGN);
+ break;
+ case IASTBinaryExpression.op_multiplyAssign:
+ opString = String.valueOf(Keywords.cpSTARASSIGN);
+ break;
+ case IASTBinaryExpression.op_divideAssign:
+ opString = String.valueOf(Keywords.cpDIVASSIGN);
+ break;
+ case IASTBinaryExpression.op_moduloAssign:
+ opString = String.valueOf(Keywords.cpMODASSIGN);
+ break;
+ case IASTBinaryExpression.op_plusAssign:
+ opString = String.valueOf(Keywords.cpPLUSASSIGN);
+ break;
+ case IASTBinaryExpression.op_minusAssign:
+ opString = String.valueOf(Keywords.cpMINUSASSIGN);
+ break;
+ case IASTBinaryExpression.op_shiftLeftAssign:
+ opString = String.valueOf(Keywords.cpSHIFTLASSIGN);
+ break;
+ case IASTBinaryExpression.op_shiftRightAssign:
+ opString = String.valueOf(Keywords.cpSHIFTRASSIGN);
+ break;
+ case IASTBinaryExpression.op_binaryAndAssign:
+ opString = String.valueOf(Keywords.cpAMPERASSIGN);
+ break;
+ case IASTBinaryExpression.op_binaryXorAssign:
+ opString = String.valueOf(Keywords.cpXORASSIGN);
+ break;
+ case IASTBinaryExpression.op_binaryOrAssign:
+ opString = String.valueOf(Keywords.cpBITORASSIGN);
+ break;
+ case IASTBinaryExpression.op_equals:
+ opString = String.valueOf(Keywords.cpEQUAL);
+ break;
+ case IASTBinaryExpression.op_notequals:
+ opString = String.valueOf(Keywords.cpNOTEQUAL);
+ break;
+ case IASTBinaryExpression.op_max:
+ opString = String.valueOf(Keywords.cpMAX);
+ break;
+ case IASTBinaryExpression.op_min:
+ opString = String.valueOf(Keywords.cpMIN);
+ break;
+ case IASTBinaryExpression.op_pmarrow:
+ opString = String.valueOf(Keywords.cpARROW);
+ break;
+ case IASTBinaryExpression.op_pmdot:
+ opString = String.valueOf(Keywords.cpDOT);
+ break;
}
-
+
return opString;
}
-
+
/**
* Returns the String representation of the IASTTypeIdExpression's operator.
*
@@ -1036,32 +1359,39 @@ public class ASTSignatureUtil {
*/
private static String getTypeIdExpressionOperator(IASTTypeIdExpression expression) {
String result = EMPTY_STRING;
-
+
if (expression instanceof IGNUASTTypeIdExpression) {
switch (expression.getOperator()) {
- case IGNUASTTypeIdExpression.op_alignof:
- result = Keywords.ALIGNOF;
- break;
- case IGNUASTTypeIdExpression.op_typeof:
- result = Keywords.TYPEOF;
- break;
+ case IGNUASTTypeIdExpression.op_alignof:
+ result = Keywords.ALIGNOF;
+ break;
+ case IGNUASTTypeIdExpression.op_typeof:
+ result = Keywords.TYPEOF;
+ break;
}
}
-
+
if (expression instanceof ICPPASTTypeIdExpression) {
- switch(expression.getOperator()) {
- case ICPPASTTypeIdExpression.op_typeid:
- result = Keywords.TYPEID;
- break;
+ switch (expression.getOperator()) {
+ case ICPPASTTypeIdExpression.op_typeid:
+ result = Keywords.TYPEID;
+ break;
}
}
-
+
if (expression.getOperator() == IASTTypeIdExpression.op_sizeof)
result = Keywords.SIZEOF;
-
+
return result;
}
+ /**
+ * Returns the String representation of the pack expansion expression.
+ */
+ private static String getPackExpansionExpression(ICPPASTPackExpansionExpression expression) {
+ return new StringBuilder().append(getExpressionString(expression.getPattern())).append(
+ Keywords.cpELLIPSIS).toString();
+ }
public static String getProblemMessage(int problemID, String detail) {
return ASTProblem.getMessage(problemID, detail);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
index d2bfdbf569f..a238b582fe4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
-import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
-
import java.util.ArrayList;
import java.util.BitSet;
import java.util.LinkedList;
@@ -27,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
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.ICPPTemplateArgument;
@@ -70,13 +69,20 @@ public class ASTTypeUtil {
String[] parms = getParameterTypeStringArray(type);
result.append(Keywords.cpLPAREN);
- for (int i = 0; i < parms.length; i++) {
- if (parms[i] != null) {
- result.append(parms[i]);
- if (i < parms.length - 1)
+ boolean needComma= false;
+ for (String parm : parms) {
+ if (parm != null) {
+ if (needComma)
result.append(COMMA_SPACE);
+ result.append(parm);
+ needComma= true;
}
}
+ if (type instanceof ICPPFunctionType && ((ICPPFunctionType) type).takesVarArgs()) {
+ if (needComma)
+ result.append(COMMA_SPACE);
+ result.append(Keywords.cpELLIPSIS);
+ }
result.append(Keywords.cpRPAREN);
return result.toString();
}
@@ -94,16 +100,10 @@ public class ASTTypeUtil {
if (parameters.length == 0) {
return false;
- } else if (parameters.length == 1) {
- IType ultimateType = SemanticUtil.getNestedType(parameters[0].getType(), TDEF);
-
- if (ultimateType instanceof IBasicType) {
- if (((IBasicType) ultimateType).getKind() == Kind.eVoid) {
- return false;
- }
- }
+ }
+ if (parameters.length == 1 && SemanticUtil.isVoidType(parameters[0].getType())) {
+ return false;
}
-
return true;
}
@@ -355,6 +355,8 @@ public class ASTTypeUtil {
} else {
result.append(Keywords.cpAMPER);
}
+ } else if (type instanceof ICPPParameterPackType) {
+ result.append(Keywords.cpELLIPSIS);
} else if (type instanceof IEnumeration) {
result.append(Keywords.ENUM);
result.append(SPACE);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java
index 8edace34a41..8bcdef58de7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java
@@ -113,6 +113,12 @@ public interface IASTUnaryExpression extends IASTExpression {
public static final int op_alignOf = 15;
/**
+ * For c++, only: 'sizeof...(parameterPack)'
+ * @since 5.2
+ */
+ public static final int op_sizeofParameterPack = 16;
+
+ /**
* <code>op_last</code> is made available for subclasses.
* @deprecated all constants must be defined in this interface
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java
index db7ac4276a7..54038f30d43 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java
@@ -6,10 +6,12 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Andrew Ferguson (Symbian) - Initial Implementation
+ * Andrew Ferguson (Symbian) - Initial Implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
@@ -25,14 +27,21 @@ public interface ICPPASTAmbiguousTemplateArgument extends IASTNode {
/**
* Add an partial parse tree that could be a suitable subtree representing
* the template argument
- * @param idExpression a non-null id-expression
+ * @param idExpression a non-null id-expression or a pack expansion of an id-expression
+ * @since 5.2
*/
- public void addIdExpression(IASTIdExpression idExpression);
-
+ public void addIdExpression(IASTExpression idExpression);
+
/**
* Add an partial parse tree that could be a suitable subtree representing
* the template argument
* @param typeId a non-null type-id
*/
public void addTypeId(IASTTypeId typeId);
+
+ /**
+ * @deprecated Replaced by {@link #addIdExpression(IASTExpression)}.
+ */
+ @Deprecated
+ public void addIdExpression(IASTIdExpression idExpression);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArrayDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArrayDeclarator.java
new file mode 100644
index 00000000000..4edeb1b52d9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArrayDeclarator.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+
+/**
+ * Array declarator for C++
+ * @since 5.2
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ICPPASTArrayDeclarator extends IASTArrayDeclarator, ICPPASTDeclarator{
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java
index 9b9bb2217f4..b9a80e70823 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java
@@ -50,87 +50,56 @@ public interface ICPPASTCompositeTypeSpecifier extends IASTCompositeTypeSpecifie
/**
* Base Specifiers are where a class expresses from whom it inherits.
*
- * @author jcamelon
* @noimplement This interface is not intended to be implemented by clients.
*/
- public static interface ICPPASTBaseSpecifier extends IASTNode, IASTNameOwner {
- /**
- * Constant.
- */
+ public static interface ICPPASTBaseSpecifier extends IASTNode, IASTNameOwner, ICPPASTPackExpandable {
public static final ICPPASTBaseSpecifier[] EMPTY_BASESPECIFIER_ARRAY = new ICPPASTBaseSpecifier[0];
/**
- * Is the keyword virtual used?
- *
- * @return boolean
- */
- public boolean isVirtual();
-
- /**
- * Set the virtual flag on/off.
- *
- * @param value
- * boolean
+ * Relation between base specifier and its name.
*/
- public void setVirtual(boolean value);
+ public static final ASTNodeProperty NAME = new ASTNodeProperty(
+ "ICPPASTBaseSpecifier.NAME - Name of base class"); //$NON-NLS-1$
- /**
- * <code>v_public</code> was public keyword used in describing this
- * base class?
- */
+
public static final int v_public = 1;
-
- /**
- * <code>v_protected</code> was protected keyword used in describing
- * this base class?
- */
public static final int v_protected = 2;
-
- /**
- * <code>v_private</code> was private keyword used in describing this
- * base class?
- */
public static final int v_private = 3;
/**
- * Get the visibility.
- *
- * @return int
+ * Returns whether this specifies a virtual base.
*/
- public int getVisibility();
+ public boolean isVirtual();
/**
- * Set the visibility.
- *
- * @param visibility
+ * Returns the accessibility for the base.
*/
- public void setVisibility(int visibility);
+ public int getVisibility();
/**
- * <code>NAME</code> is the name of the base class.
+ * Returns the name of this specifier.
*/
- public static final ASTNodeProperty NAME = new ASTNodeProperty(
- "ICPPASTBaseSpecifier.NAME - Name of base class"); //$NON-NLS-1$
+ public IASTName getName();
/**
- * Get the name.
- *
- * @return <code>IASTName</code>
+ * @since 5.1
*/
- public IASTName getName();
-
+ public ICPPASTBaseSpecifier copy();
+
/**
- * Set the name.
- *
- * @param name
- * <code>IASTName</code>
+ * Sets the name for this specifier, not allowed on frozen AST.
*/
public void setName(IASTName name);
/**
- * @since 5.1
+ * Sets whether this specifier is for a virtual base. Not allowed on frozen AST.
*/
- public ICPPASTBaseSpecifier copy();
+ public void setVirtual(boolean value);
+
+ /**
+ * Sets the visibility of this specifier, not allowed on frozen AST.
+ */
+ public void setVisibility(int visibility);
}
/**
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java
index cf14aaf4ee1..1ee336218c3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java
@@ -13,7 +13,6 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
@@ -27,7 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICPPASTConstructorChainInitializer extends IASTInitializer, IASTNameOwner {
+public interface ICPPASTConstructorChainInitializer extends ICPPASTInitializer, IASTNameOwner {
/**
* Constant.
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java
index 9d7154cc76c..eab636f08e2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java
@@ -7,12 +7,12 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTInitializer;
/**
* This is an initializer that is a call to the constructor for the declarator.
@@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializer;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICPPASTConstructorInitializer extends IASTInitializer {
+public interface ICPPASTConstructorInitializer extends ICPPASTInitializer {
/**
* <code>EXPRESSION</code> represents the expression being conusmed in a
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclarator.java
new file mode 100644
index 00000000000..5ba0b47538f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclarator.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+
+/**
+ * Declarator for c++.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.2
+ */
+public interface ICPPASTDeclarator extends IASTDeclarator {
+ /**
+ * Returns whether the declarator contains an ellipsis, in which case it declares a
+ * parameter pack.
+ */
+ public boolean declaresParameterPack();
+
+
+ /**
+ * Set whether the declarator contains an ellipsis, denoting a pack expansion.
+ * Not allowed on frozen AST.
+ */
+ public void setDeclaresParameterPack(boolean val);
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldDeclarator.java
new file mode 100644
index 00000000000..8ce67c7b858
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldDeclarator.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
+
+/**
+ * Field declarator for c++.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.2
+ */
+public interface ICPPASTFieldDeclarator extends IASTFieldDeclarator, ICPPASTDeclarator {
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java
index 5606c9b15c5..8874b708494 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java
@@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
-public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator {
+public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator, ICPPASTDeclarator {
/**
* Used as return value for {@link #getExceptionSpecification()}.
@@ -67,6 +67,11 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
public void setPureVirtual(boolean isPureVirtual);
/**
+ * @since 5.2
+ */
+ public ICPPASTParameterDeclaration[] getParameters();
+
+ /**
* Returns an array of type-ids representing the exception specification. The return value
* {@link #NO_EXCEPTION_SPECIFICATION} indicates that no exceptions are specified, whereas
* {@link IASTTypeId#EMPTY_TYPEID_ARRAY} is used for an empty exception specification.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java
new file mode 100644
index 00000000000..46a11628cb8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+
+/**
+ * Initializer for c++
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.2
+ */
+public interface ICPPASTInitializer extends IASTInitializer, ICPPASTPackExpandable {}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java
new file mode 100644
index 00000000000..835cecee6eb
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+
+/**
+ * Initializer expression for c++.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.2
+ */
+public interface ICPPASTInitializerExpression extends IASTInitializerExpression, ICPPASTInitializer {
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java
new file mode 100644
index 00000000000..594659eeb94
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
+
+/**
+ * Initializer expression for c++.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.2
+ */
+public interface ICPPASTInitializerList extends IASTInitializerList, ICPPASTInitializer {
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPackExpandable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPackExpandable.java
new file mode 100644
index 00000000000..9330f6b909d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPackExpandable.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+/**
+ * Interface for nodes that can potentially be pack-expansions.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.2
+ */
+public interface ICPPASTPackExpandable {
+ /**
+ * Returns whether this base specifier is a pack expansion.
+ * @since 5.2
+ */
+ public boolean isPackExpansion();
+
+ /**
+ * Sets whether this base specifier is a pack expansion. Not allowed on frozen AST.
+ * @since 5.2
+ */
+ public void setIsPackExpansion(boolean val);
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPackExpansionExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPackExpansionExpression.java
new file mode 100644
index 00000000000..01e36529f7d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPackExpansionExpression.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+
+/**
+ * Pack expansion as it can occur as an element in an expression-lists or as a
+ * non-type template argument.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.2
+ */
+public interface ICPPASTPackExpansionExpression extends IASTExpression {
+
+ /**
+ * Represents the relationship between a pack-expansion and its pattern.
+ */
+ public static final ASTNodeProperty PATTERN = new ASTNodeProperty("ICPPASTPackExpansionExpression.Pattern [IASTExpression]"); //$NON-NLS-1$
+
+ /**
+ * Returns the pattern of the pack expansion.
+ */
+ IASTExpression getPattern();
+
+ /**
+ * Sets the pattern of the pack expansion expression. Cannot be called on frozen ast.
+ */
+ void setPattern(IASTExpression left);
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java
index d1ca36d1570..52851caddc8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -16,11 +17,20 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICPPASTParameterDeclaration extends ICPPASTTemplateParameter,
- IASTParameterDeclaration {
+public interface ICPPASTParameterDeclaration extends ICPPASTTemplateParameter, IASTParameterDeclaration {
+
+ /**
+ * @since 5.2
+ */
+ ICPPASTParameterDeclaration[] EMPTY_CPPPARAMETERDECLARATION_ARRAY = {};
/**
* @since 5.1
*/
public ICPPASTParameterDeclaration copy();
+
+ /**
+ * @since 5.2
+ */
+ public ICPPASTDeclarator getDeclarator();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java
index ecd204a0d14..17a66bc467a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -21,8 +22,19 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICPPASTSimpleTypeTemplateParameter extends
- ICPPASTTemplateParameter, IASTNameOwner {
+public interface ICPPASTSimpleTypeTemplateParameter extends ICPPASTTemplateParameter, IASTNameOwner {
+
+ /**
+ * Relation between template parameter and its name.
+ */
+ public static final ASTNodeProperty PARAMETER_NAME = new ASTNodeProperty(
+ "ICPPASTSimpleTypeTemplateParameter.PARAMETER_NAME - The Parameter's Name"); //$NON-NLS-1$
+
+ /**
+ * Relation between template parameter and its default type.
+ */
+ public static final ASTNodeProperty DEFAULT_TYPE = new ASTNodeProperty(
+ "ICPPASTSimpleTypeTemplateParameter.DEFAULT_TYPE - Optional default TypeId value"); //$NON-NLS-1$
/**
* <code>st_class</code> represents a class.
@@ -34,60 +46,40 @@ public interface ICPPASTSimpleTypeTemplateParameter extends
*/
public static final int st_typename = 2;
+
/**
* Get the parameter type.
- *
- * @return int
*/
public int getParameterType();
-
- /**
- * Set the parameter type.
- *
- * @param value
- * int
- */
- public void setParameterType(int value);
-
+
/**
- * The parameter name.
+ * Returns the template parameter name.
*/
- public static final ASTNodeProperty PARAMETER_NAME = new ASTNodeProperty(
- "ICPPASTSimpleTypeTemplateParameter.PARAMETER_NAME - The Parameter's Name"); //$NON-NLS-1$
+ public IASTName getName();
/**
- * Get the name.
- *
- * @return <code>IASTName</code>
+ * Returns the default value (a type id) for this template parameter, or <code>null</code>.
*/
- public IASTName getName();
+ public IASTTypeId getDefaultType();
/**
- * Set the name.
- *
- * @param name
- * <code>IASTName</code>
+ * Set the parameter type.
*/
- public void setName(IASTName name);
+ public void setParameterType(int value);
/**
- * DEFAULT_TYPE is the optional default typeId value
+ * Set whether this is a parameter pack.
+ * @since 5.2
*/
- public static final ASTNodeProperty DEFAULT_TYPE = new ASTNodeProperty(
- "ICPPASTSimpleTypeTemplateParameter.DEFAULT_TYPE - Optional default TypeId value"); //$NON-NLS-1$
-
+ public void setIsParameterPack(boolean val);
+
/**
- * Get the default type.
- *
- * @return <code>IASTTypeId</code>
+ * Sets the template parameter name.
*/
- public IASTTypeId getDefaultType();
+ public void setName(IASTName name);
/**
- * Set the default type.
- *
- * @param typeId
- * <code>IASTTypeId</code>
+ * Sets the default value (a type id) for this template parameter.
*/
public void setDefaultType(IASTTypeId typeId);
@@ -95,5 +87,4 @@ public interface ICPPASTSimpleTypeTemplateParameter extends
* @since 5.1
*/
public ICPPASTSimpleTypeTemplateParameter copy();
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java
index 9237398fb86..8fb2480b56e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -19,10 +20,13 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTTemplateParameter extends IASTNode {
+ public static final ICPPASTTemplateParameter[] EMPTY_TEMPLATEPARAMETER_ARRAY = new ICPPASTTemplateParameter[0];
+
/**
- * Constant
+ * Returns whether this template parameter is a parameter pack.
+ * @since 5.2
*/
- public static final ICPPASTTemplateParameter[] EMPTY_TEMPLATEPARAMETER_ARRAY = new ICPPASTTemplateParameter[0];
+ public boolean isParameterPack();
/**
* @since 5.1
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java
index d922439b8c2..10a96be182f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -16,79 +17,72 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
- * This is a templated template parameter.
+ * This is a template template parameter as <code> V </code> in
+ * <code>template&lttemplate&lttypename T&gt class V&gt class CT;</code>
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICPPASTTemplatedTypeTemplateParameter extends
- ICPPASTTemplateParameter, IASTNameOwner {
+public interface ICPPASTTemplatedTypeTemplateParameter extends ICPPASTTemplateParameter, IASTNameOwner {
/**
- * PARAMETER
+ * Relation between template template parameter and its (nested) template parameters.
*/
public static final ASTNodeProperty PARAMETER = new ASTNodeProperty(
- "ICPPASTTemplateTypeTemplateParameter.PARAMETER - Template Parameter"); //$NON-NLS-1$
+ "ICPPASTTemplateTypeTemplateParameter.PARAMETER [ICPPASTTemplateParameter]"); //$NON-NLS-1$
/**
- * Get all template parameters.
- *
- * @return <code>ICPPASTTemplateParameter []</code>
+ * Relation between template template parameter and its name.
*/
- public ICPPASTTemplateParameter[] getTemplateParameters();
+ public static final ASTNodeProperty PARAMETER_NAME = new ASTNodeProperty(
+ "ICPPASTTemplateTypeTemplateParameter.PARAMETER_NAME [ICPPASTName]"); //$NON-NLS-1$
/**
- * Add a parameter.
- *
- * @param parm
- * <code>ICPPASTTemplateParameter</code>
+ * Relation between template template parameter and its default value.
*/
- public void addTemplateParamter(ICPPASTTemplateParameter parm);
+ public static final ASTNodeProperty DEFAULT_VALUE = new ASTNodeProperty(
+ "ICPPASTTemplateTypeTemplateParameter.DEFAULT_VALUE [IASTExpression]"); //$NON-NLS-1$
/**
- * This parameter's name.
+ * Get the nested template parameters.
*/
- public static final ASTNodeProperty PARAMETER_NAME = new ASTNodeProperty(
- "ICPPASTTemplateTypeTemplateParameter.PARAMETER_NAME - Template Parameter's Name"); //$NON-NLS-1$
+ public ICPPASTTemplateParameter[] getTemplateParameters();
/**
- * Get name.
- *
- * @return <code>IASTName</code>
+ * Get the (optional) name of this template template parameter. In case there is no name an
+ * empty name is returned.
*/
public IASTName getName();
/**
- * Set name.
- *
- * @param name
- * <code>IASTName</code>
+ * Get default value for template template parameter or <code>null</code>.
*/
- public void setName(IASTName name);
+ public IASTExpression getDefaultValue();
+
/**
- * DEFAULT_VALUE is an expession.
+ * @since 5.1
*/
- public static final ASTNodeProperty DEFAULT_VALUE = new ASTNodeProperty(
- "ICPPASTTemplateTypeTemplateParameter.DEFAULT_VALUE - Default Value is an expression"); //$NON-NLS-1$
+ public ICPPASTTemplatedTypeTemplateParameter copy();
/**
- * Get default value for template type.
- *
- * @return <code>IASTExpression</code>
+ * Add a nested template parameter.
*/
- public IASTExpression getDefaultValue();
+ public void addTemplateParamter(ICPPASTTemplateParameter parm);
/**
- * Set default value for template type.
- *
- * @param expression
- * <code>IASTExpression</code>
+ * Set whether this template template parameter is a parameter pack.
+ * @since 5.2
*/
- public void setDefaultValue(IASTExpression expression);
-
+ public void setIsParameterPack(boolean val);
+
/**
- * @since 5.1
+ * Set the name of this template template parameter.
*/
- public ICPPASTTemplatedTypeTemplateParameter copy();
+ public void setName(IASTName name);
+
+ /**
+ * Set default value for the template template parameter.
+ */
+ public void setDefaultValue(IASTExpression expression);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeId.java
new file mode 100644
index 00000000000..5f7dad418f4
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeId.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+
+/**
+ * Type ids in C++.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.2
+ */
+public interface ICPPASTTypeId extends IASTTypeId, ICPPASTPackExpandable {
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java
index 124e031d61e..bd5d43a9a28 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java
@@ -57,4 +57,14 @@ public interface ICPPFunction extends IFunction, ICPPBinding {
* @since 5.2
*/
public ICPPParameter[] getParameters() throws DOMException;
+
+ /**
+ * @since 5.2
+ */
+ public int getRequiredArgumentCount() throws DOMException;
+
+ /**
+ * @since 5.2
+ */
+ public boolean hasParameterPack();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionType.java
index 237875b3f4c..f4d01264e3d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionType.java
@@ -22,15 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IPointerType;
public interface ICPPFunctionType extends IFunctionType {
/**
- * Returns type of implicit <code>this</code>. parameter, or null, if the function
- * is not a class method or a static method.
- * @deprecated function types don't relate to this pointers at all.
- * @noreference This method is not intended to be referenced by clients.
- */
- @Deprecated
- public IPointerType getThisType();
-
- /**
* Returns <code>true</code> for a constant method
*/
public boolean isConst();
@@ -39,4 +30,18 @@ public interface ICPPFunctionType extends IFunctionType {
* Returns <code>true</code> for a volatile method
*/
public boolean isVolatile();
+
+ /**
+ * Whether the function type takes variable number of arguments.
+ * @since 5.2
+ */
+ public boolean takesVarArgs();
+
+
+ /**
+ * @deprecated function types don't relate to this pointers at all.
+ * @noreference This method is not intended to be referenced by clients and should be removed.
+ */
+ @Deprecated
+ public IPointerType getThisType();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
index c5156e87e45..cc152fa2e22 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Corporation - initial API and implementation
+ * Mike Kucera (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -32,7 +32,6 @@ import org.eclipse.cdt.core.parser.IScanner;
/**
* Factory for AST nodes for the C++ programming language.
*
- * @author Mike Kucera
* @since 5.1
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
@@ -60,8 +59,23 @@ public interface ICPPNodeFactory extends INodeFactory {
public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
+ /**
+ * @since 5.2
+ */
+ public ICPPASTDeclarator newDeclarator(IASTName name);
+
public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name);
+ /**
+ * @since 5.2
+ */
+ public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name);
+
+ /**
+ * @since 5.2
+ */
+ public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
+
public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
@@ -106,6 +120,11 @@ public interface ICPPNodeFactory extends INodeFactory {
public ICPPASTWhileStatement newWhileStatement();
+ /**
+ * @since 5.2
+ */
+ public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator);
+
public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
public IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
@@ -156,6 +175,16 @@ public interface ICPPNodeFactory extends INodeFactory {
public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name);
+ /**
+ * @since 5.2
+ */
+ public ICPPASTInitializerExpression newInitializerExpression(IASTExpression expression);
+
+ /**
+ * @since 5.2
+ */
+ public ICPPASTInitializerList newInitializerList();
+
public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp);
public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName memberInitializerId, IASTExpression initializerValue);
@@ -181,6 +210,11 @@ public interface ICPPNodeFactory extends INodeFactory {
*/
public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition, ICPPASTLiteralExpression message);
+ /**
+ * Creates a new pack expansion expression for the given pattern.
+ * @since 5.2
+ */
+ public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern);
/**
* @deprecated Replaced by {@link #newReferenceOperator(boolean)}.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java
index 871af7c7402..12ae004074e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java
@@ -28,4 +28,10 @@ public interface ICPPParameter extends IParameter, ICPPVariable {
* if there is a default value or not.
*/
public boolean hasDefaultValue();
+
+ /**
+ * Returns whether this parameter is a parameter pack.
+ * @since 5.2
+ */
+ public boolean isParameterPack();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameterPackType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameterPackType.java
new file mode 100644
index 00000000000..04200c1d03d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameterPackType.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IType;
+
+/**
+ * A parameter pack is not actually a type, however we model it as such in order
+ * to be able to represent function-types that contain parameter packs.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.2
+ */
+public interface ICPPParameterPackType extends IType {
+
+ /**
+ * Returns the pattern for the pack-expansion
+ */
+ public IType getType();
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java
index 39b9c656251..d4d1eb12c29 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java
@@ -62,4 +62,10 @@ public interface ICPPTemplateParameter extends ICPPBinding {
* @since 5.1
*/
ICPPTemplateArgument getDefaultValue();
+
+ /**
+ * Returns whether this template parameter is a parameter pack.
+ * @since 5.2
+ */
+ boolean isParameterPack();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
index 3f19de9a2f4..67ce8eb3dfb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
@@ -67,6 +67,7 @@ import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.INodeFactory;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
@@ -515,6 +516,12 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
return n;
}
+ protected final <T extends IASTNode> T setRange(T n, IASTNode from, int endOffset) {
+ final int offset = ((ASTNode) from).getOffset();
+ ((ASTNode) n).setOffsetAndLength(offset, endOffset-offset);
+ return n;
+ }
+
protected final <T extends IASTNode> T setRange(T n, int offset, int endOffset) {
((ASTNode) n).setOffsetAndLength(offset, endOffset-offset);
return n;
@@ -525,9 +532,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
adjustEndOffset(n, endOffset);
}
- protected final void adjustEndOffset(IASTNode n, final int endOffset) {
+ protected final <T extends IASTNode> T adjustEndOffset(T n, final int endOffset) {
final ASTNode node = (ASTNode) n;
node.setLength(endOffset-node.getOffset());
+ return n;
}
protected final int getEndOffset() {
@@ -914,8 +922,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
IASTExpression fExpression;
final CastAmbiguityMarker fAmbiguityMarker;
- public BinaryOperator(BinaryOperator left, IASTExpression expression, int operatorToken, int leftPrecedence, int rightPrecedence) {
- fNext= left;
+ public BinaryOperator(BinaryOperator nextOp, IASTExpression expression, int operatorToken, int leftPrecedence, int rightPrecedence) {
+ fNext= nextOp;
fOperatorToken= operatorToken;
fLeftPrecedence= leftPrecedence;
fRightPrecedence= rightPrecedence;
@@ -978,6 +986,17 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
return conditionalEx;
+ case IToken.tELLIPSIS:
+ if (right instanceof ICPPASTPackExpansionExpression) {
+ ((ICPPASTPackExpansionExpression) right).setPattern(left);
+ int endOffset= ((ASTNode) right).getLength();
+ setRange(right, left);
+ adjustEndOffset(right, endOffset);
+ return right;
+ }
+ assert false;
+ return left;
+
case IToken.tCOMMA:
IASTExpressionList list;
if (left instanceof IASTExpressionList) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
index c4f3435dec0..3f215de3c67 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
@@ -24,6 +24,7 @@ public class DeclarationOptions {
final public static int NO_FUNCTIONS= 0x40;
final public static int NO_ARRAYS= 0x80;
final public static int NO_NESTED= 0x100;
+ final public static int ALLOW_PARAMETER_PACKS= 0x200;
public static final DeclarationOptions
GLOBAL= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_CONSTRUCTOR_INITIALIZER),
@@ -31,7 +32,7 @@ public class DeclarationOptions {
C_MEMBER= new DeclarationOptions(ALLOW_BITFIELD | ALLOW_ABSTRACT),
CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD),
LOCAL= new DeclarationOptions(ALLOW_CONSTRUCTOR_INITIALIZER),
- PARAMETER= new DeclarationOptions(ALLOW_ABSTRACT),
+ PARAMETER= new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_PARAMETER_PACKS),
TYPEID= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER),
TYPEID_NEW= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED),
TYPEID_CONVERSION= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED),
@@ -47,6 +48,7 @@ public class DeclarationOptions {
final public boolean fAllowConstructorInitializer;
final public boolean fAllowFunctions;
final public boolean fAllowNested;
+ final public boolean fAllowParameterPacks;
public DeclarationOptions(int options) {
fAllowEmptySpecifier= (options & ALLOW_EMPTY_SPECIFIER) != 0;
@@ -57,5 +59,6 @@ public class DeclarationOptions {
fAllowConstructorInitializer= fAllowInitializer && (options & ALLOW_CONSTRUCTOR_INITIALIZER) != 0;
fAllowFunctions= (options & NO_FUNCTIONS) == 0;
fAllowNested= (options & NO_NESTED) == 0;
+ fAllowParameterPacks= (options & ALLOW_PARAMETER_PACKS) != 0;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java
index a7d8d0e62ee..a25152b3397 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java
@@ -25,6 +25,7 @@ public interface ITypeMarshalBuffer {
final static byte FUNCTION_TYPE= 5;
final static byte REFERENCE= 6;
final static byte POINTER_TO_MEMBER= 7;
+ final static byte PACK_EXPANSION= 8;
static final byte KIND_MASK = 0xf;
final static int FLAG1 = 0x10;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java
index 0f6c173b0eb..665fd600093 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java
@@ -448,7 +448,8 @@ public class Value implements IValue {
private static Object evaluateUnaryExpression(IASTUnaryExpression ue, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
final int unaryOp= ue.getOperator();
- if (unaryOp == IASTUnaryExpression.op_amper || unaryOp == IASTUnaryExpression.op_star)
+ if (unaryOp == IASTUnaryExpression.op_amper || unaryOp == IASTUnaryExpression.op_star ||
+ unaryOp == IASTUnaryExpression.op_sizeof || unaryOp == IASTUnaryExpression.op_sizeofParameterPack)
throw UNKNOWN_EX;
final Object value= evaluate(ue.getOperand(), unknownSigs, unknowns, maxdepth);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
index 76e37adcc82..3e80a5e342f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
@@ -259,6 +259,7 @@ public abstract class VariableReadWriteFlags {
return PDOMName.READ_ACCESS;
case IASTUnaryExpression.op_sizeof:
+ case IASTUnaryExpression.op_sizeofParameterPack:
case IGNUASTUnaryExpression.op_alignOf:
case IGNUASTUnaryExpression.op_typeof:
return 0;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclarator.java
index cc765d57694..64e6b882300 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclarator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclarator.java
@@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclarator;
@@ -28,7 +29,7 @@ import org.eclipse.core.runtime.Assert;
* <br>
* Example: void f(int (D)); // is D a type?
*/
-public class CPPASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmbiguousDeclarator {
+public class CPPASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmbiguousDeclarator, ICPPASTDeclarator {
private IASTDeclarator[] dtors = new IASTDeclarator[2];
private int dtorPos=-1;
@@ -124,4 +125,13 @@ public class CPPASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTA
assertNotFrozen();
Assert.isLegal(false);
}
+
+ public boolean declaresParameterPack() {
+ return false;
+ }
+
+ public void setDeclaresParameterPack(boolean val) {
+ assertNotFrozen();
+ Assert.isLegal(false);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java
new file mode 100644
index 00000000000..4bcc7fbe8aa
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 IBM Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
+import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
+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.IASTAmbiguousParameterDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * Handles ambiguities for ellipsis in parameter declaration.
+ * <br>
+ * template<typename... T> void function(T ...); // is T a parameter pack?
+ */
+public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implements
+ IASTAmbiguousParameterDeclaration, ICPPASTParameterDeclaration {
+
+ private ICPPASTParameterDeclaration fParameterDecl;
+
+ public CPPASTAmbiguousParameterDeclaration(ICPPASTParameterDeclaration decl) {
+ fParameterDecl= decl;
+ }
+
+ public void addParameterDeclaration(IASTParameterDeclaration d) {
+ assert false;
+ }
+
+
+ @Override
+ public IASTNode resolveAmbiguity(ASTVisitor resolver) {
+ final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent();
+
+ // Setup the ast to use the alternative
+ owner.replace(this, fParameterDecl);
+
+ IType t= CPPVisitor.createParameterType(fParameterDecl, true);
+ if (!(t instanceof ICPPParameterPackType) ||
+ !SemanticUtil.containsParameterPack(((ICPPParameterPackType) t).getType())) {
+ final ICPPASTDeclarator dtor = fParameterDecl.getDeclarator();
+ dtor.setDeclaresParameterPack(false);
+ adjustOffsets(dtor);
+ ((ICPPASTFunctionDeclarator) fParameterDecl.getParent()).setVarArgs(true);
+ }
+ return fParameterDecl;
+ }
+
+ private void adjustOffsets(final ICPPASTDeclarator dtor) {
+ IASTPointerOperator[] ptrOps= dtor.getPointerOperators();
+ final ASTNode asNode = (ASTNode) dtor;
+ if (ptrOps.length > 0) {
+ final ASTNode first = (ASTNode)ptrOps[0];
+ final ASTNode last = (ASTNode)ptrOps[ptrOps.length-1];
+ asNode.setOffsetAndLength(first.getOffset(), last.getOffset() + last.getLength());
+ } else {
+ asNode.setOffsetAndLength(0, 0);
+ }
+ }
+
+ public IASTParameterDeclaration[] getParameterDeclarations() {
+ return new IASTParameterDeclaration[] {fParameterDecl};
+ }
+
+ @Override
+ public IASTNode[] getNodes() {
+ return getParameterDeclarations();
+ }
+
+ public IASTDeclSpecifier getDeclSpecifier() {
+ return fParameterDecl.getDeclSpecifier();
+ }
+
+ public ICPPASTDeclarator getDeclarator() {
+ return fParameterDecl.getDeclarator();
+ }
+
+ public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
+ Assert.isLegal(false);
+ }
+
+ public void setDeclarator(IASTDeclarator declarator) {
+ Assert.isLegal(false);
+ }
+
+ public ICPPASTParameterDeclaration copy() {
+ Assert.isLegal(false);
+ return null;
+ }
+
+ public boolean isParameterPack() {
+ Assert.isLegal(false);
+ return true;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java
index e41dece1cd1..f38dbc9e6a2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java
@@ -12,17 +12,18 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import com.ibm.icu.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
-import org.eclipse.cdt.internal.core.parser.ParserMessages;
+import org.eclipse.core.runtime.Assert;
/**
* Ambiguity node for deciding between type-id and id-expression in a template argument.
@@ -32,21 +33,22 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements
private List<IASTNode> fNodes;
/**
- * @param nodes nodes of type {@link IASTTypeId} or {@link IASTIdExpression}
- */
- /*
- * We can replace this with a version taking ICPPASTTemplateArgument...
- * in the future
+ * @param nodes nodes of type {@link IASTTypeId}, {@link IASTIdExpression} or {@link ICPPASTPackExpansionExpression}.
*/
public CPPASTAmbiguousTemplateArgument(IASTNode... nodes) {
fNodes= new ArrayList<IASTNode>(2);
for(IASTNode node : nodes) {
- if(node instanceof IASTTypeId || node instanceof IASTIdExpression) {
+ if (node instanceof IASTTypeId || node instanceof IASTIdExpression) {
fNodes.add(node);
+ } else if (node instanceof ICPPASTPackExpansionExpression) {
+ final IASTExpression pattern = ((ICPPASTPackExpansionExpression) node).getPattern();
+ if (pattern instanceof IASTIdExpression) {
+ fNodes.add(node);
+ } else {
+ Assert.isLegal(false, pattern == null ? "null" : pattern.getClass().getName()); //$NON-NLS-1$
+ }
} else {
- String ns= node == null ? "null" : node.getClass().getName(); //$NON-NLS-1$
- String msg= MessageFormat.format(ParserMessages.getString("CPPASTAmbiguousTemplateArgument_InvalidConstruction"), new Object[] {ns}); //$NON-NLS-1$
- throw new IllegalArgumentException(msg);
+ Assert.isLegal(false, node == null ? "null" : node.getClass().getName()); //$NON-NLS-1$
}
}
}
@@ -69,7 +71,12 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements
assertNotFrozen();
addNode(idExpression);
}
-
+
+ public void addIdExpression(IASTExpression idExpression) {
+ assertNotFrozen();
+ addNode(idExpression);
+ }
+
private void addNode(IASTNode node) {
fNodes.add(node);
node.setParent(this);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayDeclarator.java
index bc606c885ff..9539f783f77 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayDeclarator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayDeclarator.java
@@ -1,27 +1,27 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - 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.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
/**
- * @author jcamelon
+ * Array declarator for c++.
*/
-public class CPPASTArrayDeclarator extends CPPASTDeclarator implements IASTArrayDeclarator {
+public class CPPASTArrayDeclarator extends CPPASTDeclarator implements ICPPASTArrayDeclarator {
private IASTArrayModifier [] arrayMods = null;
private int arrayModsPos=-1;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java
index 8f24e23f8ab..4426121805a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - Initial API and implementation
* Bryan Wilkinson (QNX)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
@@ -27,14 +27,14 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
/**
- * @author jcamelon
+ * Base class specifier
*/
-public class CPPASTBaseSpecifier extends ASTNode implements
- ICPPASTBaseSpecifier, IASTCompletionContext {
+public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier, IASTCompletionContext {
private boolean isVirtual;
private int visibility;
private IASTName name;
+ private boolean fIsPackExpansion;
public CPPASTBaseSpecifier() {
@@ -54,6 +54,7 @@ public class CPPASTBaseSpecifier extends ASTNode implements
CPPASTBaseSpecifier copy = new CPPASTBaseSpecifier(name == null ? null : name.copy());
copy.isVirtual = isVirtual;
copy.visibility = visibility;
+ copy.fIsPackExpansion= fIsPackExpansion;
copy.setOffsetAndLength(this);
return copy;
}
@@ -129,9 +130,9 @@ public class CPPASTBaseSpecifier extends ASTNode implements
}
}
- for (int i = 0; i < bindings.length; i++) {
- if (bindings[i] instanceof ICPPClassType) {
- ICPPClassType base = (ICPPClassType) bindings[i];
+ for (IBinding binding : bindings) {
+ if (binding instanceof ICPPClassType) {
+ ICPPClassType base = (ICPPClassType) binding;
try {
int key = base.getKey();
if (key == ICPPClassType.k_class &&
@@ -145,4 +146,13 @@ public class CPPASTBaseSpecifier extends ASTNode implements
return filtered.toArray(new IBinding[filtered.size()]);
}
+
+ public boolean isPackExpansion() {
+ return fIsPackExpansion;
+ }
+
+ public void setIsPackExpansion(boolean val) {
+ assertNotFrozen();
+ fIsPackExpansion= val;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
index f1969520b3e..f595db5c936 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
@@ -43,6 +43,7 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
private IASTName name;
private IASTExpression value;
+ private boolean fIsPackExpansion;
public CPPASTConstructorChainInitializer() {
@@ -58,6 +59,7 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
copy.setMemberInitializerId(name == null ? null : name.copy());
copy.setInitializerValue(value == null ? null : value.copy());
copy.setOffsetAndLength(this);
+ copy.fIsPackExpansion= fIsPackExpansion;
return copy;
}
@@ -173,4 +175,13 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
return null;
}
+
+ public boolean isPackExpansion() {
+ return fIsPackExpansion;
+ }
+
+ public void setIsPackExpansion(boolean val) {
+ assertNotFrozen();
+ fIsPackExpansion= val;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java
index ec68d7846ff..acc4f311e31 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -18,12 +19,13 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
- * @author jcamelon
+ * Initializer in parenthesis.
*/
public class CPPASTConstructorInitializer extends ASTNode implements
ICPPASTConstructorInitializer, IASTAmbiguityParent {
private IASTExpression exp;
+ private boolean fIsPackExpansion;
public CPPASTConstructorInitializer() {
@@ -36,6 +38,7 @@ public class CPPASTConstructorInitializer extends ASTNode implements
public CPPASTConstructorInitializer copy() {
CPPASTConstructorInitializer copy = new CPPASTConstructorInitializer(exp == null ? null : exp.copy());
copy.setOffsetAndLength(this);
+ copy.fIsPackExpansion= fIsPackExpansion;
return copy;
}
@@ -79,4 +82,13 @@ public class CPPASTConstructorInitializer extends ASTNode implements
exp = (IASTExpression) other;
}
}
+
+ public boolean isPackExpansion() {
+ return fIsPackExpansion;
+ }
+
+ public void setIsPackExpansion(boolean val) {
+ assertNotFrozen();
+ fIsPackExpansion= val;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java
index b2a77f10b0f..d7d2035bc52 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java
@@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@@ -34,12 +35,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/**
* C++ specific declarator.
*/
-public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
+public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator {
private IASTInitializer initializer;
private IASTName name;
private IASTDeclarator nested;
private IASTPointerOperator[] pointerOps = null;
- private int pointerOpsPos= -1;
+ private boolean isPackExpansion;
public CPPASTDeclarator() {
}
@@ -64,14 +65,19 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
copy.setName(name == null ? null : name.copy());
copy.setInitializer(initializer == null ? null : initializer.copy());
copy.setNestedDeclarator(nested == null ? null : nested.copy());
+ copy.isPackExpansion= isPackExpansion;
for(IASTPointerOperator pointer : getPointerOperators())
copy.addPointerOperator(pointer == null ? null : pointer.copy());
copy.setOffsetAndLength(this);
}
+ public boolean declaresParameterPack() {
+ return isPackExpansion;
+ }
+
public IASTPointerOperator[] getPointerOperators() {
if (pointerOps == null) return IASTPointerOperator.EMPTY_ARRAY;
- pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter(IASTPointerOperator.class, pointerOps, pointerOpsPos);
+ pointerOps = (IASTPointerOperator[]) ArrayUtil.trim(IASTPointerOperator.class, pointerOps);
return pointerOps;
}
@@ -101,7 +107,7 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
if (operator != null) {
operator.setParent(this);
operator.setPropertyInParent(POINTER_OPERATOR);
- pointerOps = (IASTPointerOperator[]) ArrayUtil.append(IASTPointerOperator.class, pointerOps, ++pointerOpsPos, operator);
+ pointerOps = (IASTPointerOperator[]) ArrayUtil.append(IASTPointerOperator.class, pointerOps, operator);
}
}
@@ -122,8 +128,13 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
name.setPropertyInParent(DECLARATOR_NAME);
}
}
+
+ public void setDeclaresParameterPack(boolean val) {
+ assertNotFrozen();
+ isPackExpansion= val;
+ }
- @Override
+ @Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclarators) {
switch(action.visit(this)) {
@@ -133,9 +144,13 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
}
}
- for (int i = 0; i <= pointerOpsPos; i++) {
- if (!pointerOps[i].accept(action))
- return false;
+ if (pointerOps != null) {
+ for (IASTPointerOperator op : pointerOps) {
+ if (op == null)
+ break;
+ if (!op.accept(action))
+ return false;
+ }
}
if (nested == null && name != null) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java
index 34ea4a14ca3..b4a0ca750dc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java
@@ -1,32 +1,31 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - 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.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
- * @author jcamelon
+ * Field declarator for c++.
*/
public class CPPASTFieldDeclarator extends CPPASTDeclarator implements
- IASTFieldDeclarator, IASTAmbiguityParent {
+ ICPPASTFieldDeclarator, IASTAmbiguityParent {
private IASTExpression bitField;
-
-
+
public CPPASTFieldDeclarator() {
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java
index 22ac6d7e455..15a5010521f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java
@@ -19,18 +19,19 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
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.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* Represents a function declarator.
*/
-public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPASTFunctionDeclarator {
- private IASTParameterDeclaration[] parameters = null;
- private int parametersPos = -1;
+public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPASTFunctionDeclarator,
+ IASTAmbiguityParent {
+ private ICPPASTParameterDeclaration[] parameters = null;
private IASTTypeId[] typeIds = NO_EXCEPTION_SPECIFICATION;
- private int typeIdsPos = -1;
private boolean varArgs;
private boolean pureVirtual;
@@ -63,11 +64,11 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
return copy;
}
- public IASTParameterDeclaration[] getParameters() {
+ public ICPPASTParameterDeclaration[] getParameters() {
if (parameters == null)
- return IASTParameterDeclaration.EMPTY_PARAMETERDECLARATION_ARRAY;
+ return ICPPASTParameterDeclaration.EMPTY_CPPPARAMETERDECLARATION_ARRAY;
- return parameters= ArrayUtil.trimAt(IASTParameterDeclaration.class, parameters, parametersPos);
+ return parameters= ArrayUtil.trim(parameters);
}
public void addParameterDeclaration(IASTParameterDeclaration parameter) {
@@ -75,7 +76,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
if (parameter != null) {
parameter.setParent(this);
parameter.setPropertyInParent(FUNCTION_PARAMETER);
- parameters = (IASTParameterDeclaration[]) ArrayUtil.append(IASTParameterDeclaration.class, parameters, ++parametersPos, parameter);
+ parameters = (ICPPASTParameterDeclaration[]) ArrayUtil.append(ICPPASTParameterDeclaration.class, parameters, parameter);
}
}
@@ -107,7 +108,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
}
public IASTTypeId[] getExceptionSpecification() {
- return typeIds= ArrayUtil.trimAt(IASTTypeId.class, typeIds, typeIdsPos);
+ return typeIds= ArrayUtil.trim(typeIds);
}
public void setEmptyExceptionSpecification() {
@@ -118,7 +119,8 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
public void addExceptionSpecificationTypeId(IASTTypeId typeId) {
assertNotFrozen();
if (typeId != null) {
- typeIds = (IASTTypeId[]) ArrayUtil.append(IASTTypeId.class, typeIds, ++typeIdsPos, typeId);
+ assert typeIds != null;
+ typeIds = ArrayUtil.append(typeIds, typeId);
typeId.setParent(this);
typeId.setPropertyInParent(EXCEPTION_TYPEID);
}
@@ -135,7 +137,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
@Deprecated
public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer[] getConstructorChain() {
- if (CPPVisitor.findTypeRelevantDeclarator(this) == this) {
+ if (ASTQueries.findTypeRelevantDeclarator(this) == this) {
IASTNode parent= getParent();
while(!(parent instanceof IASTDeclaration)) {
if (parent == null)
@@ -168,7 +170,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
if (node instanceof IASTParameterDeclaration)
return null;
- if (CPPVisitor.findTypeRelevantDeclarator(this) == this) {
+ if (ASTQueries.findTypeRelevantDeclarator(this) == this) {
scope = new CPPFunctionScope(this);
}
return scope;
@@ -190,4 +192,18 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
return super.postAccept(action);
}
+
+ public void replace(IASTNode child, IASTNode other) {
+ if (parameters != null) {
+ for (int i = 0; i < parameters.length; ++i) {
+ if (child == parameters[i]) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ parameters[i] = (ICPPASTParameterDeclaration) other;
+ return;
+ }
+ }
+ }
+ assert false;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java
index 3e65fab8672..cd9cf256770 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java
@@ -1,29 +1,31 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - 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.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerExpression;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
- * @author jcamelon
+ * Initializer expression.
*/
public class CPPASTInitializerExpression extends ASTNode implements
- IASTInitializerExpression, IASTAmbiguityParent {
+ ICPPASTInitializerExpression, IASTAmbiguityParent {
private IASTExpression exp;
+ private boolean fIsPackExpansion;
public CPPASTInitializerExpression() {
@@ -36,6 +38,7 @@ public class CPPASTInitializerExpression extends ASTNode implements
public CPPASTInitializerExpression copy() {
CPPASTInitializerExpression copy = new CPPASTInitializerExpression(exp == null ? null : exp.copy());
copy.setOffsetAndLength(this);
+ copy.fIsPackExpansion= fIsPackExpansion;
return copy;
}
@@ -80,5 +83,13 @@ public class CPPASTInitializerExpression extends ASTNode implements
exp = (IASTExpression) other;
}
}
+ public boolean isPackExpansion() {
+ return fIsPackExpansion;
+ }
+
+ public void setIsPackExpansion(boolean val) {
+ assertNotFrozen();
+ fIsPackExpansion= val;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java
index 125b8e1f196..aaafa5126ac 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java
@@ -13,17 +13,18 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
* e.g.: int a[]= {1,2,3};
*/
-public class CPPASTInitializerList extends ASTNode implements IASTInitializerList {
+public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializerList {
private IASTInitializer [] initializers = null;
private int initializersPos=-1;
private int actualLength;
+ private boolean fIsPackExpansion;
public CPPASTInitializerList copy() {
CPPASTInitializerList copy = new CPPASTInitializerList();
@@ -31,6 +32,7 @@ public class CPPASTInitializerList extends ASTNode implements IASTInitializerLis
copy.addInitializer(initializer == null ? null : initializer.copy());
copy.setOffsetAndLength(this);
copy.actualLength= getSize();
+ copy.fIsPackExpansion= fIsPackExpansion;
return copy;
}
@@ -80,5 +82,14 @@ public class CPPASTInitializerList extends ASTNode implements IASTInitializerLis
}
return true;
}
+
+ public boolean isPackExpansion() {
+ return fIsPackExpansion;
+ }
+
+ public void setIsPackExpansion(boolean val) {
+ assertNotFrozen();
+ fIsPackExpansion= val;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java
new file mode 100644
index 00000000000..4bb26e48e9c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
+import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
+
+/**
+ * Implementation of pack expansion expression.
+ */
+public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPackExpansionExpression, IASTAmbiguityParent {
+
+ private IASTExpression fPattern;
+
+ public CPPASTPackExpansionExpression(IASTExpression pattern) {
+ setPattern(pattern);
+ }
+
+ public void setPattern(IASTExpression pattern) {
+ assertNotFrozen();
+
+ fPattern= pattern;
+ if (pattern != null) {
+ pattern.setParent(this);
+ pattern.setPropertyInParent(ICPPASTPackExpansionExpression.PATTERN);
+ }
+ }
+
+
+ public IASTExpression getPattern() {
+ return fPattern;
+ }
+
+ public IASTExpression copy() {
+ CPPASTPackExpansionExpression copy = new CPPASTPackExpansionExpression(fPattern.copy());
+ copy.setOffsetAndLength(this);
+ return copy;
+ }
+
+ public IType getExpressionType() {
+ return new CPPParameterPackType(fPattern.getExpressionType());
+ }
+
+ public boolean isLValue() {
+ return fPattern.isLValue();
+ }
+
+ @Override
+ public boolean accept(ASTVisitor visitor) {
+ if (visitor.shouldVisitExpressions) {
+ switch (visitor.visit(this)) {
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
+ default : break;
+ }
+ }
+ if (!fPattern.accept(visitor)) {
+ return false;
+ }
+ if (visitor.shouldVisitExpressions && visitor.leave(this) == ASTVisitor.PROCESS_ABORT) {
+ return false;
+ }
+ return true;
+ }
+
+ public void replace(IASTNode child, IASTNode other) {
+ if (child == fPattern) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ fPattern = (IASTExpression) other;
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java
index f65910f0a29..e7b367ca3a8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -15,18 +15,19 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
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.CPPVisitor;
/**
- * @author jcamelon
+ * Function parameter or non-type template parameter declaration.
*/
public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParameterDeclaration, IASTAmbiguityParent {
- private IASTDeclSpecifier declSpec;
- private IASTDeclarator declarator;
-
+ private IASTDeclSpecifier fDeclSpec;
+ private ICPPASTDeclarator fDeclarator;
public CPPASTParameterDeclaration() {
}
@@ -36,25 +37,29 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame
setDeclarator(declarator);
}
+ public boolean isParameterPack() {
+ return fDeclarator != null && CPPVisitor.findInnermostDeclarator(fDeclarator).declaresParameterPack();
+ }
+
public CPPASTParameterDeclaration copy() {
CPPASTParameterDeclaration copy = new CPPASTParameterDeclaration();
- copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy());
- copy.setDeclarator(declarator == null ? null : declarator.copy());
+ copy.setDeclSpecifier(fDeclSpec == null ? null : fDeclSpec.copy());
+ copy.setDeclarator(fDeclarator == null ? null : fDeclarator.copy());
copy.setOffsetAndLength(this);
return copy;
}
public IASTDeclSpecifier getDeclSpecifier() {
- return declSpec;
+ return fDeclSpec;
}
- public IASTDeclarator getDeclarator() {
- return declarator;
+ public ICPPASTDeclarator getDeclarator() {
+ return fDeclarator;
}
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
assertNotFrozen();
- this.declSpec = declSpec;
+ this.fDeclSpec = declSpec;
if (declSpec != null) {
declSpec.setParent(this);
declSpec.setPropertyInParent(DECL_SPECIFIER);
@@ -63,10 +68,12 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame
public void setDeclarator(IASTDeclarator declarator) {
assertNotFrozen();
- this.declarator = declarator;
- if (declarator != null) {
+ if (declarator instanceof ICPPASTDeclarator) {
+ fDeclarator = (ICPPASTDeclarator) declarator;
declarator.setParent(this);
declarator.setPropertyInParent(DECLARATOR);
+ } else {
+ fDeclarator= null;
}
}
@@ -80,8 +87,8 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame
}
}
- if( declSpec != null ) if( !declSpec.accept( action ) ) return false;
- if( declarator != null ) if( !declarator.accept( action ) ) return false;
+ if( fDeclSpec != null ) if( !fDeclSpec.accept( action ) ) return false;
+ if( fDeclarator != null ) if( !fDeclarator.accept( action ) ) return false;
if( action.shouldVisitParameterDeclarations ){
switch( action.leave( this ) ){
@@ -94,10 +101,10 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame
}
public void replace(IASTNode child, IASTNode other) {
- if (child == declarator) {
+ if (child == fDeclarator) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
- declarator= (IASTDeclarator) other;
+ fDeclarator= (ICPPASTDeclarator) other;
}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java
index 9eb0d2b2427..5c928c1cac2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -19,49 +19,60 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
- * @author jcamelon
+ * Template type parameter as in <code>template &lttypename T&gt class X;</code>
*/
-public class CPPASTSimpleTypeTemplateParameter extends ASTNode implements
- ICPPASTSimpleTypeTemplateParameter {
+public class CPPASTSimpleTypeTemplateParameter extends ASTNode implements ICPPASTSimpleTypeTemplateParameter {
- private int type;
- private IASTName name;
- private IASTTypeId typeId;
+ private IASTName fName;
+ private IASTTypeId fTypeId;
+ private boolean fUsesKeywordClass;
+ private boolean fIsParameterPack;
public CPPASTSimpleTypeTemplateParameter() {
}
public CPPASTSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId) {
- this.type = type;
+ fUsesKeywordClass= type == st_class;
setName(name);
setDefaultType(typeId);
}
public CPPASTSimpleTypeTemplateParameter copy() {
CPPASTSimpleTypeTemplateParameter copy = new CPPASTSimpleTypeTemplateParameter();
- copy.type = type;
- copy.setName(name == null ? null : name.copy());
- copy.setDefaultType(typeId == null ? null : typeId.copy());
+ copy.fUsesKeywordClass = fUsesKeywordClass;
+ copy.fIsParameterPack= fIsParameterPack;
+ copy.setName(fName == null ? null : fName.copy());
+ copy.setDefaultType(fTypeId == null ? null : fTypeId.copy());
copy.setOffsetAndLength(this);
return copy;
}
+
+ public boolean isParameterPack() {
+ return fIsParameterPack;
+ }
+
+ public void setIsParameterPack(boolean val) {
+ assertNotFrozen();
+ fIsParameterPack= val;
+ }
+
public int getParameterType() {
- return type;
+ return fUsesKeywordClass ? st_class : st_typename;
}
public void setParameterType(int value) {
assertNotFrozen();
- this.type = value;
+ fUsesKeywordClass = value == st_class;
}
public IASTName getName() {
- return name;
+ return fName;
}
public void setName(IASTName name) {
assertNotFrozen();
- this.name = name;
+ this.fName = name;
if (name != null) {
name.setParent(this);
name.setPropertyInParent(PARAMETER_NAME);
@@ -69,12 +80,12 @@ public class CPPASTSimpleTypeTemplateParameter extends ASTNode implements
}
public IASTTypeId getDefaultType() {
- return typeId;
+ return fTypeId;
}
public void setDefaultType(IASTTypeId typeId) {
assertNotFrozen();
- this.typeId = typeId;
+ this.fTypeId = typeId;
if (typeId != null) {
typeId.setParent(this);
typeId.setPropertyInParent(DEFAULT_TYPE);
@@ -91,8 +102,8 @@ public class CPPASTSimpleTypeTemplateParameter extends ASTNode implements
}
}
- if (name != null) if (!name.accept(action)) return false;
- if (typeId != null) if (!typeId.accept(action)) return false;
+ if (fName != null) if (!fName.accept(action)) return false;
+ if (fTypeId != null) if (!fTypeId.accept(action)) return false;
if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) {
switch (((ICPPASTVisitor) action).leave(this)) {
@@ -105,7 +116,7 @@ public class CPPASTSimpleTypeTemplateParameter extends ASTNode implements
}
public int getRoleForName(IASTName n) {
- if (n == name)
+ if (n == fName)
return r_declaration;
return r_unclear;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java
index f33661b4266..1684ba771ae 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -23,12 +23,16 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
- * @author jcamelon
+ * Template template parameter
*/
public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements
ICPPASTTemplatedTypeTemplateParameter, IASTAmbiguityParent {
-
+ private ICPPASTTemplateParameter [] fNestedParameters = null;
+ private boolean fIsParameterPack;
+ private IASTName fName;
+ private IASTExpression fDefaultValue;
+
public CPPASTTemplatedTypeTemplateParameter() {
}
@@ -39,8 +43,9 @@ public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements
public CPPASTTemplatedTypeTemplateParameter copy() {
CPPASTTemplatedTypeTemplateParameter copy = new CPPASTTemplatedTypeTemplateParameter();
- copy.setName(name == null ? null : name.copy());
- copy.setDefaultValue(defaultValue == null ? null : defaultValue.copy());
+ copy.setName(fName == null ? null : fName.copy());
+ copy.setDefaultValue(fDefaultValue == null ? null : fDefaultValue.copy());
+ copy.fIsParameterPack= fIsParameterPack;
for(ICPPASTTemplateParameter param : getTemplateParameters())
copy.addTemplateParamter(param == null ? null : param.copy());
copy.setOffsetAndLength(this);
@@ -48,32 +53,39 @@ public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements
}
public ICPPASTTemplateParameter[] getTemplateParameters() {
- if( parameters == null ) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY;
- parameters = (ICPPASTTemplateParameter[]) ArrayUtil.removeNullsAfter( ICPPASTTemplateParameter.class, parameters, parametersPos );
- return parameters;
- }
+ if (fNestedParameters == null)
+ return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY;
+ fNestedParameters = (ICPPASTTemplateParameter[]) ArrayUtil.trim(ICPPASTTemplateParameter.class, fNestedParameters);
+ return fNestedParameters;
+ }
- public void addTemplateParamter(ICPPASTTemplateParameter parm) {
- assertNotFrozen();
- if(parm != null) {
- parameters = (ICPPASTTemplateParameter[]) ArrayUtil.append( ICPPASTTemplateParameter.class, parameters, ++parametersPos, parm );
- parm.setParent(this);
+ public void addTemplateParamter(ICPPASTTemplateParameter parm) {
+ assertNotFrozen();
+ if (parm != null) {
+ fNestedParameters = (ICPPASTTemplateParameter[]) ArrayUtil.append(ICPPASTTemplateParameter.class,
+ fNestedParameters, parm);
+ parm.setParent(this);
parm.setPropertyInParent(PARAMETER);
- }
- }
+ }
+ }
+
+
+ public void setIsParameterPack(boolean val) {
+ assertNotFrozen();
+ fIsParameterPack= val;
+ }
- private ICPPASTTemplateParameter [] parameters = null;
- private int parametersPos=-1;
- private IASTName name;
- private IASTExpression defaultValue;
+ public boolean isParameterPack() {
+ return fIsParameterPack;
+ }
- public IASTName getName() {
- return name;
+ public IASTName getName() {
+ return fName;
}
public void setName(IASTName name) {
assertNotFrozen();
- this.name =name;
+ this.fName =name;
if (name != null) {
name.setParent(this);
name.setPropertyInParent(PARAMETER_NAME);
@@ -81,12 +93,12 @@ public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements
}
public IASTExpression getDefaultValue() {
- return defaultValue;
+ return fDefaultValue;
}
public void setDefaultValue(IASTExpression expression) {
assertNotFrozen();
- this.defaultValue = expression;
+ this.fDefaultValue = expression;
if (expression != null) {
expression.setParent(this);
expression.setPropertyInParent(DEFAULT_VALUE);
@@ -107,8 +119,8 @@ public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements
for ( int i = 0; i < ps.length; i++ ) {
if( !ps[i].accept( action ) ) return false;
}
- if( name != null ) if( !name.accept( action ) ) return false;
- if( defaultValue != null ) if( !defaultValue.accept( action ) ) return false;
+ if( fName != null ) if( !fName.accept( action ) ) return false;
+ if( fDefaultValue != null ) if( !fDefaultValue.accept( action ) ) return false;
if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) {
switch( ((ICPPASTVisitor)action).leave( this ) ){
@@ -121,17 +133,17 @@ public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements
}
public int getRoleForName(IASTName n) {
- if( n == name )
+ if( n == fName )
return r_declaration;
return r_unclear;
}
public void replace(IASTNode child, IASTNode other) {
- if( child == defaultValue )
+ if( child == fDefaultValue )
{
other.setPropertyInParent( child.getPropertyInParent() );
other.setParent( child.getParent() );
- defaultValue = (IASTExpression) other;
+ fDefaultValue = (IASTExpression) other;
}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeId.java
index db9a1ffccba..9bd8015d4da 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeId.java
@@ -1,28 +1,30 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * 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:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - 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.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
-import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
- * @author jcamelon
+ * Type id for c++
*/
-public class CPPASTTypeId extends ASTNode implements IASTTypeId {
+public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
private IASTDeclSpecifier declSpec;
private IASTDeclarator absDecl;
+ private boolean isPackExpansion;
public CPPASTTypeId() {
@@ -38,6 +40,7 @@ public class CPPASTTypeId extends ASTNode implements IASTTypeId {
copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy());
copy.setAbstractDeclarator(absDecl == null ? null : absDecl.copy());
copy.setOffsetAndLength(this);
+ copy.isPackExpansion= isPackExpansion;
return copy;
}
@@ -68,7 +71,15 @@ public class CPPASTTypeId extends ASTNode implements IASTTypeId {
}
}
- @Override
+ public boolean isPackExpansion() {
+ return isPackExpansion;
+ }
+
+ public void setIsPackExpansion(boolean val) {
+ isPackExpansion= val;
+ }
+
+ @Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitTypeIds ){
switch( action.visit( this ) ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java
index 0ce2d33aa31..c12f05b808a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java
@@ -205,6 +205,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
final int op= getOperator();
switch (op) {
case op_sizeof:
+ case op_sizeofParameterPack:
return CPPVisitor.get_SIZE_T(this);
case op_typeid:
return CPPVisitor.get_type_info(this);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java
index a87c445fc33..985117457bc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java
@@ -107,4 +107,8 @@ public class CPPBuiltinParameter extends PlatformObject implements ICPPParameter
public IValue getInitialValue() {
return null;
}
+
+ public boolean isParameterPack() {
+ return false;
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
index 6f486d8ac40..24042721dd2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemplateInstance {
private ICPPTemplateArgument[] arguments;
- public CPPClassInstance(IBinding owner, ICPPClassType orig, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) {
+ public CPPClassInstance(ICPPClassType orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) {
super(orig, owner, argMap);
this.arguments= args;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
index 5b162214929..7d6f66f2368 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
@@ -277,7 +277,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
return false;
}
- public ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
+ public final ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
if (fDeferredInstance == null) {
fDeferredInstance= createDeferredInstance();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java
index e53fb6d70ba..4d36ad00929 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 QNX Software Systems and others.
+ * Copyright (c) 2007, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,9 +21,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
*/
public class CPPConstructorInstance extends CPPMethodInstance implements ICPPConstructor {
- public CPPConstructorInstance(ICPPClassType owner, ICPPConstructor orig,
+ public CPPConstructorInstance(ICPPConstructor orig, ICPPClassType owner,
CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args) {
- super(owner, orig, tpmap, args);
+ super(orig, owner, tpmap, args);
}
public boolean isExplicit() throws DOMException {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java
index dbabf66e8f0..7b44b13adf5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -12,7 +12,6 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
@@ -23,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
public class CPPConstructorSpecialization extends CPPMethodSpecialization
implements ICPPConstructor {
- public CPPConstructorSpecialization(IBinding orig, ICPPClassType owner,
+ public CPPConstructorSpecialization(ICPPConstructor orig, ICPPClassType owner,
ICPPTemplateParameterMap argMap) {
super(orig, owner, argMap);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java
index 7eec02e378c..d643f89abf9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -12,7 +12,6 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
@@ -23,9 +22,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
public class CPPConstructorTemplateSpecialization extends CPPMethodTemplateSpecialization
implements ICPPConstructor {
- public CPPConstructorTemplateSpecialization(IBinding specialized,
+ public CPPConstructorTemplateSpecialization(ICPPConstructor original,
ICPPClassType owner, ICPPTemplateParameterMap tpmap) {
- super(specialized, owner, tpmap);
+ super(original, owner, tpmap);
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
index 7a319b71192..dc19ada3def 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
@@ -48,6 +48,7 @@ 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.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -107,6 +108,15 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
public IType[] getExceptionSpecification() throws DOMException {
throw new DOMException(this);
}
+ public int getRequiredArgumentCount() throws DOMException {
+ throw new DOMException(this);
+ }
+ public boolean hasParameterPack() {
+ return false;
+ }
+ public boolean hasSameFunctionParameterTypeList(ICPPFunction function) {
+ return false;
+ }
}
protected IASTDeclarator[] declarations;
@@ -574,4 +584,29 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
}
return null;
}
+
+ public int getRequiredArgumentCount() throws DOMException {
+ return getRequiredArgumentCount(getParameters());
+ }
+
+ public static int getRequiredArgumentCount(ICPPParameter[] pars) throws DOMException {
+ int result= pars.length;
+ while(result > 0) {
+ final ICPPParameter p = pars[result-1];
+ if (p.hasDefaultValue() || p.isParameterPack()) {
+ result--;
+ } else {
+ if (pars.length == 1 && SemanticUtil.isVoidType(p.getType())) {
+ return 0;
+ }
+ return result;
+ }
+ }
+ return 0;
+ }
+
+ public boolean hasParameterPack() {
+ ICPPParameter[] pars= getParameters();
+ return pars.length > 0 && pars[pars.length-1].isParameterPack();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java
index f187a36d640..1b84257783a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance {
private ICPPTemplateArgument[] fArguments;
- public CPPFunctionInstance(IBinding owner, ICPPFunction orig, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) {
+ public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) {
super(orig, owner, argMap);
fArguments = args;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
index 0fb26af565d..de58803f982 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
@@ -40,10 +40,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
*/
public class CPPFunctionSpecialization extends CPPSpecialization implements ICPPFunction, ICPPInternalFunction {
private ICPPFunctionType type = null;
- private ICPPParameter[] specializedParams = null;
+ private ICPPParameter[] fParams = null;
private IType[] specializedExceptionSpec = null;
- public CPPFunctionSpecialization(IBinding orig, IBinding owner, ICPPTemplateParameterMap argMap) {
+ public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap) {
super(orig, owner, argMap);
}
@@ -52,25 +52,38 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
}
public ICPPParameter[] getParameters() throws DOMException {
- if (specializedParams == null) {
- ICPPFunction function = (ICPPFunction) getSpecializedBinding();
+ if (fParams == null) {
+ ICPPFunction function = getFunction();
ICPPParameter[] params = function.getParameters();
- specializedParams = new ICPPParameter[params.length];
- for (int i = 0; i < params.length; i++) {
- specializedParams[i] = new CPPParameterSpecialization(params[i],
- this, getTemplateParameterMap());
+ if (params.length == 0) {
+ fParams= params;
+ } else {
+ // Because of parameter packs there can be more or less parameters in the specialization
+ final ICPPTemplateParameterMap tparMap = getTemplateParameterMap();
+ IType[] ptypes= getType().getParameterTypes();
+ final int length = ptypes.length;
+ ICPPParameter par= null;
+ fParams = new ICPPParameter[length];
+ for (int i = 0; i < length; i++) {
+ if (i < params.length) {
+ par= params[i];
+ } // else reuse last parameter (which should be a pack)
+ fParams[i] = new CPPParameterSpecialization(par, this, ptypes[i], tparMap);
+ }
}
}
- return specializedParams;
+ return fParams;
+ }
+
+ public int getRequiredArgumentCount() throws DOMException {
+ return ((ICPPFunction) getSpecializedBinding()).getRequiredArgumentCount();
+ }
+
+ public boolean hasParameterPack() {
+ return ((ICPPFunction) getSpecializedBinding()).hasParameterPack();
}
public IScope getFunctionScope() {
-// resolveAllDeclarations();
-// if (definition != null) {
-// return definition.getFunctionScope();
-// }
-//
-// return declarations[0].getFunctionScope();
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
index 2a22fc3da3d..03469779805 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
@@ -103,6 +103,12 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
public IType[] getExceptionSpecification() throws DOMException {
throw new DOMException( this );
}
+ public int getRequiredArgumentCount() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean hasParameterPack() {
+ return false;
+ }
}
protected ICPPFunctionType type = null;
@@ -176,6 +182,16 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
return CPPBuiltinParameter.createParameterList(getType());
}
+
+ public int getRequiredArgumentCount() throws DOMException {
+ return CPPFunction.getRequiredArgumentCount(getParameters());
+ }
+
+ public boolean hasParameterPack() {
+ ICPPParameter[] pars= getParameters();
+ return pars.length > 0 && pars[pars.length-1].isParameterPack();
+ }
+
public IScope getFunctionScope() {
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplateSpecialization.java
index d1a26a37922..d976ad8323d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplateSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplateSpecialization.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
@@ -30,8 +31,8 @@ public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
private ObjectMap instances = null;
- public CPPFunctionTemplateSpecialization(IBinding specialized, ICPPClassType owner, ICPPTemplateParameterMap argumentMap) {
- super(specialized, owner, argumentMap);
+ public CPPFunctionTemplateSpecialization(ICPPFunction original, ICPPClassType owner, ICPPTemplateParameterMap argumentMap) {
+ super(original, owner, argumentMap);
}
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java
index 48c66820f66..57e58e68e02 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java
@@ -12,11 +12,9 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
-import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
-import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
@@ -31,6 +29,7 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
private IType returnType;
private boolean isConst;
private boolean isVolatile;
+ private boolean takesVarargs;
/**
* @param returnType
@@ -41,11 +40,13 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
this.parameters = types;
}
- public CPPFunctionType(IType returnType, IType[] types, boolean isConst, boolean isVolatile) {
+ public CPPFunctionType(IType returnType, IType[] types, boolean isConst, boolean isVolatile,
+ boolean takesVarargs) {
this.returnType = returnType;
this.parameters = types;
this.isConst = isConst;
this.isVolatile= isVolatile;
+ this.takesVarargs= takesVarargs;
}
public boolean isSameType(IType o) {
@@ -53,6 +54,10 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
return o.isSameType(this);
if (o instanceof ICPPFunctionType) {
ICPPFunctionType ft = (ICPPFunctionType) o;
+ if (isConst() != ft.isConst() || isVolatile() != ft.isVolatile() || takesVarArgs() != ft.takesVarArgs()) {
+ return false;
+ }
+
IType[] fps;
fps = ft.getParameterTypes();
//constructors & destructors have null return type
@@ -62,12 +67,10 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
return false;
if (parameters.length == 1 && fps.length == 0) {
- IType p0= SemanticUtil.getNestedType(parameters[0], SemanticUtil.TDEF);
- if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getKind() != Kind.eVoid)
+ if (!SemanticUtil.isVoidType(parameters[0]))
return false;
} else if (fps.length == 1 && parameters.length == 0) {
- IType p0= SemanticUtil.getNestedType(fps[0], SemanticUtil.TDEF);
- if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getKind() != Kind.eVoid)
+ if (!SemanticUtil.isVoidType(fps[0]))
return false;
} else if (parameters.length != fps.length) {
return false;
@@ -77,11 +80,7 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
return false;
}
}
-
- if (isConst() != ft.isConst() || isVolatile() != ft.isVolatile()) {
- return false;
- }
-
+
return true;
}
return false;
@@ -125,6 +124,10 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
return isVolatile;
}
+ public boolean takesVarArgs() {
+ return takesVarargs;
+ }
+
@Override
public String toString() {
return ASTTypeUtil.getType(this);
@@ -134,10 +137,11 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
int firstByte= ITypeMarshalBuffer.FUNCTION_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
+ if (takesVarArgs()) firstByte |= ITypeMarshalBuffer.FLAG3;
int len= (parameters.length & 0xffff);
if (len > 0xff) {
- firstByte |= ITypeMarshalBuffer.FLAG3;
+ firstByte |= ITypeMarshalBuffer.FLAG4;
buffer.putByte((byte) firstByte);
buffer.putShort((short) len);
} else {
@@ -153,7 +157,7 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int len;
- if (((firstByte & ITypeMarshalBuffer.FLAG3) != 0)) {
+ if (((firstByte & ITypeMarshalBuffer.FLAG4) != 0)) {
len= buffer.getShort();
} else {
len= buffer.getByte();
@@ -164,6 +168,6 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
pars[i]= buffer.unmarshalType();
}
return new CPPFunctionType(rt, pars, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
- (firstByte & ITypeMarshalBuffer.FLAG2) != 0);
+ (firstByte & ITypeMarshalBuffer.FLAG2) != 0, (firstByte & ITypeMarshalBuffer.FLAG3) != 0);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java
index b1a74485d4e..6635e53cd66 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java
@@ -19,11 +19,9 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
-import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
@@ -37,6 +35,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
/**
* Binding for implicit methods, base class for implicit constructors.
@@ -139,9 +138,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
ok = idx == ps.length;
} else if (ps.length == 0) {
if (params.length == 1) {
- IType t1 = params[0];
- ok = (t1 instanceof IBasicType)
- && ((IBasicType) t1).getKind() == Kind.eVoid;
+ ok = SemanticUtil.isVoidType(params[0]);
}
}
} else {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java
index e96611519e9..a24beb76902 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -21,8 +21,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
*/
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
- public CPPMethodInstance(ICPPClassType owner, ICPPMethod orig, CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args) {
- super(owner, orig, tpmap, args);
+ public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args) {
+ super(orig, owner, tpmap, args);
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java
index c167d1217d5..d5531f13e80 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
-import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
@@ -29,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
public class CPPMethodSpecialization extends CPPFunctionSpecialization
implements ICPPMethod {
- public CPPMethodSpecialization(IBinding orig, ICPPClassType owner, ICPPTemplateParameterMap argMap ) {
+ public CPPMethodSpecialization(ICPPMethod orig, ICPPClassType owner, ICPPTemplateParameterMap argMap ) {
super(orig, owner, argMap );
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java
index e75a17b0a5e..14058959a5d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpecialization
implements ICPPMethod {
- public CPPMethodTemplateSpecialization(IBinding specialized, ICPPClassType owner,
+ public CPPMethodTemplateSpecialization(ICPPMethod specialized, ICPPClassType owner,
ICPPTemplateParameterMap ctmap) {
super(specialized, owner, ctmap);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
index fd14a698f56..1fe4146c505 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
@@ -12,7 +12,6 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
-import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
@@ -28,13 +27,10 @@ import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
-import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
@@ -50,6 +46,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdInitializerExpression;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
@@ -58,10 +55,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
@@ -69,6 +68,8 @@ 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.ICPPASTFunctionWithTryBlock;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
@@ -76,6 +77,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
@@ -91,6 +93,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
+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.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
@@ -324,11 +327,11 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new CPPASTTypeIdExpression(operator, typeId);
}
- public IASTDeclarator newDeclarator(IASTName name) {
+ public ICPPASTDeclarator newDeclarator(IASTName name) {
return new CPPASTDeclarator(name);
}
- public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
+ public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
return new CPPASTTypeId(declSpecifier, declarator);
}
@@ -340,7 +343,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new CPPASTSimpleDeclaration(declSpecifier);
}
- public IASTInitializerExpression newInitializerExpression(IASTExpression expression) {
+ public ICPPASTInitializerExpression newInitializerExpression(IASTExpression expression) {
return new CPPASTInitializerExpression(expression);
}
@@ -469,7 +472,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new GPPASTPointerToMember(name);
}
- public IASTInitializerList newInitializerList() {
+ public ICPPASTInitializerList newInitializerList() {
return new CPPASTInitializerList();
}
@@ -481,7 +484,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new CPPASTArrayModifier(expr);
}
- public IASTArrayDeclarator newArrayDeclarator(IASTName name) {
+ public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name) {
return new CPPASTArrayDeclarator(name);
}
@@ -498,7 +501,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return new CPPASTFunctionWithTryBlock(declSpecifier, declarator, bodyStatement);
}
- public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
+ public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
return new CPPASTFieldDeclarator(name, bitFieldSize);
}
@@ -522,4 +525,8 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
ICPPASTLiteralExpression message) {
return new CPPASTStaticAssertionDeclaration(condition, message);
}
+
+ public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern) {
+ return new CPPASTPackExpansionExpression(pattern);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
index ccc28b74943..599e7495cfe 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
@@ -26,6 +26,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
@@ -34,7 +36,6 @@ 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.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -81,28 +82,35 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
public IValue getInitialValue() {
return null;
}
+ public boolean isParameterPack() {
+ return false;
+ }
}
- private IType type = null;
- private IASTName[] declarations = null;
+ private IType fType = null;
+ private IASTName[] fDeclarations = null;
private int fPosition;
public CPPParameter(IASTName name, int pos) {
- this.declarations = new IASTName[] { name };
+ this.fDeclarations = new IASTName[] { name };
fPosition= pos;
}
public CPPParameter(IType type, int pos) {
- this.type = type;
+ this.fType = type;
fPosition= pos;
}
- /* (non-Javadoc)
+ public boolean isParameterPack() {
+ return getType() instanceof ICPPParameterPackType;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
*/
public IASTNode[] getDeclarations() {
- return declarations;
+ return fDeclarations;
}
/* (non-Javadoc)
@@ -116,29 +124,29 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
if (!(node instanceof IASTName))
return;
IASTName name = (IASTName) node;
- if (declarations == null) {
- declarations = new IASTName[] { name };
+ if (fDeclarations == null) {
+ fDeclarations = new IASTName[] { name };
} else {
//keep the lowest offset declaration in[0]
- if (declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode)declarations[0]).getOffset()) {
- declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name);
+ if (fDeclarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode)fDeclarations[0]).getOffset()) {
+ fDeclarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, fDeclarations, name);
} else {
- declarations = (IASTName[]) ArrayUtil.append(IASTName.class, declarations, name);
+ fDeclarations = (IASTName[]) ArrayUtil.append(IASTName.class, fDeclarations, name);
}
}
}
private IASTName getPrimaryDeclaration() {
- if (declarations != null) {
- for (int i = 0; i < declarations.length && declarations[i] != null; i++) {
- IASTNode node = declarations[i].getParent();
+ if (fDeclarations != null) {
+ for (int i = 0; i < fDeclarations.length && fDeclarations[i] != null; i++) {
+ IASTNode node = fDeclarations[i].getParent();
while (!(node instanceof IASTDeclaration))
node = node.getParent();
if (node instanceof IASTFunctionDefinition)
- return declarations[i];
+ return fDeclarations[i];
}
- return declarations[0];
+ return fDeclarations[0];
}
return null;
}
@@ -170,8 +178,8 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
*/
public IASTNode getPhysicalNode() {
- if (declarations != null)
- return declarations[0];
+ if (fDeclarations != null)
+ return fDeclarations[0];
return null;
}
@@ -179,11 +187,17 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
*/
public IType getType() {
- if (type == null && declarations != null) {
- IType t= CPPVisitor.createType((IASTDeclarator) declarations[0].getParent());
- type= SemanticUtil.adjustParameterType(t, false);
+ if (fType == null && fDeclarations != null) {
+ IASTNode parent= fDeclarations[0].getParent();
+ while (parent != null) {
+ if (parent instanceof ICPPASTParameterDeclaration) {
+ fType= CPPVisitor.createParameterType((ICPPASTParameterDeclaration) parent, false);
+ break;
+ }
+ parent= parent.getParent();
+ }
}
- return type;
+ return fType;
}
/* (non-Javadoc)
@@ -268,10 +282,10 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
}
public IASTInitializer getDefaultValue() {
- if (declarations == null)
+ if (fDeclarations == null)
return null;
- for (int i = 0; i < declarations.length && declarations[i] != null; i++) {
- IASTNode parent = declarations[i].getParent();
+ for (int i = 0; i < fDeclarations.length && fDeclarations[i] != null; i++) {
+ IASTNode parent = fDeclarations[i].getParent();
while (parent.getPropertyInParent() == IASTDeclarator.NESTED_DECLARATOR)
parent = parent.getParent();
IASTInitializer init = ((IASTDeclarator)parent).getInitializer();
@@ -300,7 +314,7 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
}
public IBinding getOwner() throws DOMException {
- return CPPVisitor.findEnclosingFunction(declarations[0]);
+ return CPPVisitor.findEnclosingFunction(fDeclarations[0]);
}
public IValue getInitialValue() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterPackType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterPackType.java
new file mode 100644
index 00000000000..67d8ba673c9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterPackType.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
+import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
+import org.eclipse.core.runtime.CoreException;
+
+public class CPPParameterPackType implements ICPPParameterPackType, ITypeContainer, ISerializableType {
+ private IType fType = null;
+
+ public CPPParameterPackType(IType type) {
+ setType(type);
+ }
+
+ public IType getType() {
+ return fType;
+ }
+
+ public void setType(IType t) {
+ fType= t;
+ }
+
+ public boolean isSameType(IType obj) {
+ if (obj == this)
+ return true;
+ if (obj instanceof ITypedef)
+ return ((ITypedef)obj).isSameType(this);
+
+ if (obj instanceof ICPPParameterPackType) {
+ final ICPPParameterPackType rhs = (ICPPParameterPackType) obj;
+ IType t1= getType();
+ IType t2= rhs.getType();
+ return t1 != null && t1.isSameType(t2);
+ }
+ return false;
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ // not going to happen
+ return null;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return ASTTypeUtil.getType(this);
+ }
+
+ public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
+ int firstByte= ITypeMarshalBuffer.PACK_EXPANSION;
+ buffer.putByte((byte) firstByte);
+ buffer.marshalType(getType());
+ }
+
+ public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ IType nested= buffer.unmarshalType();
+ return new CPPParameterPackType(nested);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java
index a16f7a8be8d..b7bd1409b5d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java
@@ -15,19 +15,19 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
/**
* Binding for a specialization of a parameter.
*/
public class CPPParameterSpecialization extends CPPSpecialization implements ICPPParameter {
- private IType type = null;
+ private IType fType;
- public CPPParameterSpecialization(ICPPParameter orig, IBinding owner, ICPPTemplateParameterMap tpmap) {
+ public CPPParameterSpecialization(ICPPParameter orig, IBinding owner, IType type, ICPPTemplateParameterMap tpmap) {
super(orig, owner, tpmap);
+ fType= type;
}
private ICPPParameter getParameter(){
@@ -38,25 +38,17 @@ public class CPPParameterSpecialization extends CPPSpecialization implements ICP
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
*/
public IType getType() throws DOMException {
- if( type == null ){
- type= specializeType(getParameter().getType());
- }
- return type;
+ return fType;
}
+ public boolean isParameterPack() {
+ return fType instanceof ICPPParameterPackType;
+ }
+
@Override
public IType specializeType(IType type) {
- IBinding owner= getOwner();
- if (owner != null) {
- try {
- owner= owner.getOwner();
- if (owner instanceof ICPPClassSpecialization) {
- return CPPTemplates.instantiateType(type, getTemplateParameterMap(), (ICPPClassSpecialization) owner);
- }
- } catch (DOMException e) {
- }
- }
- return CPPTemplates.instantiateType(type, getTemplateParameterMap(), null);
+ assert false;
+ return type;
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
index 3482ce4a0dc..75cf9a85905 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
@@ -20,6 +20,8 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.internal.core.dom.parser.Value;
@@ -68,14 +70,23 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
}
public IType getType() {
- if( type == null ){
- IASTName name = getPrimaryDeclaration();
- IASTDeclarator dtor = (IASTDeclarator) name.getParent();
- type = CPPVisitor.createType( dtor );
+ if (type == null) {
+ IASTNode parent= getPrimaryDeclaration().getParent();
+ while (parent != null) {
+ if (parent instanceof ICPPASTParameterDeclaration) {
+ type= CPPVisitor.createParameterType((ICPPASTParameterDeclaration) parent, true);
+ break;
+ }
+ parent= parent.getParent();
+ }
}
return type;
}
+ public boolean isParameterPack() {
+ return getType() instanceof ICPPParameterPackType;
+ }
+
public boolean isStatic() throws DOMException {
return false;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java
index ed5a45b0361..8a1cea4e7af 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java
@@ -50,9 +50,15 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
private ICPPTemplateParameter[] templateParameters;
private ObjectMap instances;
private ICPPScope unknownScope;
-
- public CPPTemplateTemplateParameter(IASTName name) {
+ private final boolean fIsParameterPack;
+
+ public CPPTemplateTemplateParameter(IASTName name, boolean isPack) {
super(name);
+ fIsParameterPack= isPack;
+ }
+
+ public final boolean isParameterPack() {
+ return fIsParameterPack;
}
public ICPPScope asScope() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java
index 98288c83a36..33a4d9141e5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java
@@ -29,9 +29,15 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
ICPPTemplateTypeParameter, ICPPUnknownType, ICPPUnknownBinding {
private ICPPScope unknownScope;
+ private final boolean fIsParameterPack;
- public CPPTemplateTypeParameter(IASTName name) {
+ public CPPTemplateTypeParameter(IASTName name, boolean isPack) {
super(name);
+ fIsParameterPack= isPack;
+ }
+
+ public final boolean isParameterPack() {
+ return fIsParameterPack;
}
public ICPPScope asScope() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java
index 16a1f6ffa5a..0f77af4e1dc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java
@@ -89,4 +89,12 @@ public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunctio
public boolean takesVarArgs() throws DOMException {
return false;
}
+
+ public int getRequiredArgumentCount() throws DOMException {
+ return 0;
+ }
+
+ public boolean hasParameterPack() {
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java
index 26952c3e472..8dcc5004c87 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java
@@ -29,7 +29,6 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
-import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
@@ -38,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
-import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
@@ -669,8 +667,8 @@ public class ClassTypeHelper {
if (params.length == 0)
return KIND_DEFAULT_CTOR;
if (params.length == 1) {
- IType t= params[0];
- if (t instanceof IBasicType && ((IBasicType) t).getKind() == Kind.eVoid)
+ IType t= SemanticUtil.getNestedType(params[0], SemanticUtil.TDEF);
+ if (SemanticUtil.isVoidType(t))
return KIND_DEFAULT_CTOR;
if (isRefToConstClass(ct, t))
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index 98d5a71f0af..2b351a9a233 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -16,6 +16,7 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@@ -32,18 +33,14 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTPointer;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IASTProblem;
@@ -60,6 +57,7 @@ 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.ICPPASTAmbiguousTemplateArgument;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
@@ -67,15 +65,20 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
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.ICPPASTFunctionWithTryBlock;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
@@ -98,6 +101,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
+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.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
@@ -105,6 +109,7 @@ 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.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
@@ -129,6 +134,8 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException;
import org.eclipse.cdt.internal.core.dom.parser.DeclarationOptions;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
@@ -140,7 +147,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
*/
public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private static final int DEFAULT_PARM_LIST_SIZE = 4;
- private static final int DEFAULT_POINTEROPS_LIST_SIZE = 4;
private static final int DEFAULT_CATCH_HANDLER_LIST_SIZE= 4;
private static enum DtorStrategy {PREFER_FUNCTION, PREFER_NESTED}
@@ -350,7 +356,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
/**
- * Makes a fast check whether there could be template arguments.
+ * Makes a fast check whether there could be template arguments.
+ * -1: no, 0: ambiguous, 1: yes
*/
private int canBeTemplateArguments(CastExprCtx ctx) throws EndOfFileException, BacktrackException {
if (LTcatchEOF(1) != IToken.tLT)
@@ -390,11 +397,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
lt1= LTcatchEOF(2);
}
switch(lt1) {
- // can be some cast-expression or continuation after template-id
+ // Can be some cast-expression or continuation after template-id
case IToken.tCOLONCOLON: // CT<int>::member
case IToken.tLPAREN: // ft<int>(args)
return 0;
- // end of an expression
+ // Start of other expressions (then we can't have a template)
// unary expression
case IToken.tMINUS:
case IToken.tPLUS:
@@ -450,6 +457,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.tRBRACE:
case IToken.tRBRACKET:
case IToken.tRPAREN:
+ case IToken.tELLIPSIS: // pack-expansion
return 1;
// don't know
default:
@@ -505,82 +513,106 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
private List<IASTNode> templateArgumentList(boolean isAmbiguous) throws EndOfFileException, BacktrackException {
- IToken start = LA(1);
- int startingOffset = start.getOffset();
+ int startingOffset = LA(1).getOffset();
int endOffset = 0;
- start = null;
- List<IASTNode> list = new ArrayList<IASTNode>();
+ List<IASTNode> list= null;
final BinaryExprCtx exprCtx = isAmbiguous ? BinaryExprCtx.eAmbigTmplID : BinaryExprCtx.eTmplID;
- boolean failed = false;
+ boolean needComma= false;
int lt1= LT(1);
while (lt1 != IToken.tGT && lt1 != IToken.tGT_in_SHIFTR && lt1 != IToken.tEOC) {
- IToken argStart = mark();
- IASTTypeId typeId = typeId(DeclarationOptions.TYPEID);
-
- lt1 = LT(1);
- if(typeId != null && (lt1==IToken.tCOMMA || lt1==IToken.tGT || lt1 == IToken.tGT_in_SHIFTR || lt1==IToken.tEOC)) {
- // potentially a type-id - check for id-expression ambiguity
- IToken typeIdEnd= mark();
- try {
- // consider ambiguity with id-expressions, only:
- IASTDeclSpecifier declspec= typeId.getDeclSpecifier();
- if (!(declspec instanceof IASTNamedTypeSpecifier))
- throw backtrack;
- IASTName name= ((IASTNamedTypeSpecifier) declspec).getName();
- if (!name.contains(typeId))
- throw backtrack;
-
- // A template-id cannot be used in an id-expression as a template argument
- // 5.1-11 A template-id shall be used as an unqualified-id only as specified in
- // 14.7.2, 14.7, and 14.5.4.
- name= name.getLastName();
- if (name instanceof ICPPASTTemplateId)
- throw backtrack;
-
- backup(argStart);
- IASTExpression expression = expression(ExprKind.eAssignment, exprCtx);
- if (expression instanceof IASTIdExpression) {
- if (mark() != typeIdEnd)
- throw backtrack;
-
- ICPPASTAmbiguousTemplateArgument ambiguity= createAmbiguousTemplateArgument();
- ambiguity.addTypeId(typeId);
- ambiguity.addIdExpression((IASTIdExpression) expression);
- list.add(ambiguity);
- } else {
- // prefer the typeId at this stage
- throw backtrack;
- }
- } catch (BacktrackException e) {
- // no ambiguity - its a type-id
- list.add(typeId);
- backup(typeIdEnd);
- }
- } else {
- // not a type-id - try as expression
- backup(argStart);
- IASTExpression expression = expression(ExprKind.eAssignment, exprCtx);
- list.add(expression);
- }
-
+ if (needComma) {
+ if (lt1 != IToken.tCOMMA) {
+ throwBacktrack(startingOffset, endOffset - startingOffset);
+ }
+ consume();
+ } else {
+ needComma= true;
+ }
+
+ IASTNode node= templateArgument(exprCtx);
+ if (list == null) {
+ list= new ArrayList<IASTNode>();
+ }
+ list.add(node);
lt1= LT(1);
- if (lt1 == IToken.tCOMMA) {
- consume();
- lt1= LT(1);
- } else if (lt1 != IToken.tGT && lt1 != IToken.tGT_in_SHIFTR && lt1 != IToken.tEOC) {
- failed = true;
- endOffset = LA(1).getEndOffset();
- break;
- }
}
- if (failed)
- throwBacktrack(startingOffset, endOffset - startingOffset);
-
+ if (list == null) {
+ return Collections.emptyList();
+ }
return list;
}
- private IASTName operatorId() throws BacktrackException, EndOfFileException {
+ private IASTNode templateArgument(BinaryExprCtx exprCtx) throws EndOfFileException, BacktrackException {
+ IToken argStart = mark();
+ final ICPPASTTypeId typeId = typeId(DeclarationOptions.TYPEID);
+
+ final int lt1 = LT(1);
+ if (typeId != null
+ && (lt1 == IToken.tCOMMA || lt1 == IToken.tGT || lt1 == IToken.tGT_in_SHIFTR
+ || lt1 == IToken.tEOC || lt1 == IToken.tELLIPSIS)) {
+ // This is potentially a type-id, now check ambiguity with id-expression
+ IASTDeclSpecifier declspec= typeId.getDeclSpecifier();
+ if (declspec instanceof IASTNamedTypeSpecifier) {
+ IASTName name= ((IASTNamedTypeSpecifier) declspec).getName();
+ if (name.contains(typeId)) {
+ // A template-id cannot be used in an id-expression as a template argument
+ // 5.1-11 A template-id shall be used as an unqualified-id only as specified in
+ // 14.7.2, 14.7, and 14.5.4.
+ name= name.getLastName();
+ if (!(name instanceof ICPPASTTemplateId)) {
+ IToken typeIdEnd= mark();
+ backup(argStart);
+ try {
+ IASTExpression expression = expression(ExprKind.eAssignment, exprCtx);
+ if (expression instanceof IASTIdExpression) {
+ if (mark() == typeIdEnd) {
+ if (LT(1) == IToken.tELLIPSIS) {
+ IToken ellipsis= consume();
+ addPackExpansion(typeId, ellipsis);
+ expression= addPackExpansion(expression, ellipsis);
+ }
+ ICPPASTAmbiguousTemplateArgument ambiguity= createAmbiguousTemplateArgument();
+ ambiguity.addTypeId(typeId);
+ ambiguity.addIdExpression(expression);
+ return ambiguity;
+ }
+ }
+ } catch (BacktrackException e) {
+ // Use the typeId
+ }
+ backup(typeIdEnd);
+ }
+ }
+ }
+ // There is no ambiguity, use the type-id
+ if (LT(1) == IToken.tELLIPSIS) {
+ addPackExpansion(typeId, consume());
+ }
+ return typeId;
+ }
+
+ // Not a type-id, parse as expression
+ backup(argStart);
+ IASTExpression expr= expression(ExprKind.eAssignment, exprCtx);
+ if (LT(1) == IToken.tELLIPSIS) {
+ expr= addPackExpansion(expr, consume());
+ }
+ return expr;
+ }
+
+ private void addPackExpansion(ICPPASTTypeId typeId, IToken consume) {
+ final int endOffset= consume.getEndOffset();
+ adjustEndOffset(typeId, endOffset);
+ typeId.setIsPackExpansion(true);
+ }
+
+ private IASTExpression addPackExpansion(IASTExpression expr, IToken ellipsis) {
+ IASTExpression result= nodeFactory.newPackExpansionExpression(expr);
+ return setRange(result, expr, ellipsis.getEndOffset());
+ }
+
+ private IASTName operatorId() throws BacktrackException, EndOfFileException {
final IToken firstToken = consume(IToken.t_operator);
int endOffset= firstToken.getEndOffset();
IASTTypeId typeId = null;
@@ -705,6 +737,18 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
allowThrow= true;
break;
+ case IToken.tELLIPSIS:
+ if ((!allowComma && conditionCount == 0))
+ break loop;
+
+ // Precedence: To the left just stronger than ',', to the right no other choice.
+ lastOperator= new BinaryOperator(lastOperator, expr, lt1, 12, Integer.MAX_VALUE);
+ expr= nodeFactory.newPackExpansionExpression(null);
+ setRange(expr, 0, consume().getEndOffset());
+ if (LT(1) == IToken.tCOMMA)
+ continue loop;
+ break loop;
+
case IToken.tCOMMA:
allowThrow= true;
if (!allowComma && conditionCount == 0)
@@ -1024,6 +1068,23 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return postfixExpression(ctx);
}
case IToken.t_sizeof:
+ if (LTcatchEOF(2) == IToken.tELLIPSIS) {
+ int offset= consume().getOffset(); // sizeof
+ consume(); // ...
+ consume(IToken.tLPAREN); // (
+ IASTName id= identifier();
+ IASTIdExpression idexpr= nodeFactory.newIdExpression(id);
+ setRange(idexpr, id);
+ IASTUnaryExpression expr= nodeFactory.newUnaryExpression(IASTUnaryExpression.op_sizeofParameterPack, idexpr);
+ final int lt1= LT(1);
+ if (lt1 == IToken.tEOC) {
+ setRange(expr, offset, calculateEndOffset(id));
+ } else {
+ final int endOffset = consume(IToken.tRPAREN).getEndOffset(); // )
+ setRange(expr, offset, endOffset);
+ }
+ return expr;
+ }
return parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(),
IASTTypeIdExpression.op_sizeof, IASTUnaryExpression.op_sizeof, ctx);
case IGCCToken.t_typeof:
@@ -1628,63 +1689,81 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
final int lt1= LT(1);
if (lt1 == IToken.tGT || lt1 == IToken.tEOC || lt1 == IToken.tGT_in_SHIFTR)
return returnValue;
+
+ final int offset = LA(1).getOffset();
if (lt1 == IToken.t_class || lt1 == IToken.t_typename) {
- IToken startingToken = LA(1);
- int lastOffset = 0;
int type = (lt1 == IToken.t_class ? ICPPASTSimpleTypeTemplateParameter.st_class
: ICPPASTSimpleTypeTemplateParameter.st_typename);
- lastOffset = consume().getEndOffset();
+ boolean parameterPack= false;
IASTName identifierName = null;
- IASTTypeId typeId = null;
-
+ IASTTypeId defaultValue = null;
+ int endOffset = consume().getEndOffset();
+
+ if (LT(1) == IToken.tELLIPSIS) {
+ parameterPack= true;
+ endOffset= consume().getOffset();
+ }
if (LT(1) == IToken.tIDENTIFIER) { // optional identifier
identifierName = identifier();
- lastOffset = calculateEndOffset(identifierName);
+ endOffset = calculateEndOffset(identifierName);
if (LT(1) == IToken.tASSIGN) { // optional = type-id
+ if (parameterPack)
+ throw backtrack;
consume();
- typeId = typeId(DeclarationOptions.TYPEID); // type-id
- if (typeId == null)
+ defaultValue = typeId(DeclarationOptions.TYPEID); // type-id
+ if (defaultValue == null)
throw backtrack;
- lastOffset = calculateEndOffset(typeId);
+ endOffset = calculateEndOffset(defaultValue);
}
} else {
identifierName = nodeFactory.newName();
}
- ICPPASTSimpleTypeTemplateParameter parm = nodeFactory.newSimpleTypeTemplateParameter(type, identifierName, typeId);
- ((ASTNode) parm).setOffsetAndLength(startingToken.getOffset(), lastOffset - startingToken.getOffset());
- returnValue.add(parm);
+ ICPPASTSimpleTypeTemplateParameter tpar = nodeFactory.newSimpleTypeTemplateParameter(type, identifierName, defaultValue);
+ tpar.setIsParameterPack(parameterPack);
+ setRange(tpar, offset, endOffset);
+ returnValue.add(tpar);
} else if (lt1 == IToken.t_template) {
- IToken firstToken = consume();
- consume(IToken.tLT);
+ boolean parameterPack= false;
+ IASTName identifierName = null;
+ IASTExpression defaultValue = null;
- List<ICPPASTTemplateParameter> subResult = templateParameterList();
+ consume();
+ consume(IToken.tLT);
+ List<ICPPASTTemplateParameter> tparList = templateParameterList();
consume(IToken.tGT, IToken.tGT_in_SHIFTR);
- int last = consume(IToken.t_class).getEndOffset();
- IASTName identifierName = null;
- IASTExpression optionalExpression = null;
+ int endOffset = consume(IToken.t_class).getEndOffset();
+
+ if (LT(1) == IToken.tELLIPSIS) {
+ parameterPack= true;
+ endOffset= consume().getOffset();
+ }
if (LT(1) == IToken.tIDENTIFIER) { // optional identifier
identifierName = identifier();
- last = calculateEndOffset(identifierName);
+ endOffset = calculateEndOffset(identifierName);
if (LT(1) == IToken.tASSIGN) { // optional = type-id
+ if (parameterPack)
+ throw backtrack;
+
consume();
- optionalExpression = primaryExpression(CastExprCtx.eNotBExpr);
- last = calculateEndOffset(optionalExpression);
+ defaultValue = primaryExpression(CastExprCtx.eNotBExpr);
+ endOffset = calculateEndOffset(defaultValue);
}
- } else
+ } else {
identifierName = nodeFactory.newName();
-
- ICPPASTTemplatedTypeTemplateParameter parm = nodeFactory.newTemplatedTypeTemplateParameter(identifierName, optionalExpression);
- ((ASTNode) parm).setOffsetAndLength(firstToken.getOffset(), last - firstToken.getOffset());
-
- for (int i = 0; i < subResult.size(); ++i) {
- ICPPASTTemplateParameter p = subResult.get(i);
- parm.addTemplateParamter(p);
}
- returnValue.add(parm);
+
+ ICPPASTTemplatedTypeTemplateParameter tpar = nodeFactory.newTemplatedTypeTemplateParameter(identifierName, defaultValue);
+ tpar.setIsParameterPack(parameterPack);
+ setRange(tpar, offset, endOffset);
+ for (int i = 0; i < tparList.size(); ++i) {
+ ICPPASTTemplateParameter p = tparList.get(i);
+ tpar.addTemplateParamter(p);
+ }
+ returnValue.add(tpar);
} else if (lt1 == IToken.tCOMMA) {
consume();
continue;
@@ -2045,6 +2124,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
ICPPASTConstructorChainInitializer ctorInitializer = nodeFactory.newConstructorChainInitializer(name, expressionList);
+ if (LT(1) == IToken.tELLIPSIS) {
+ ctorInitializer.setIsPackExpansion(true);
+ endOffset= consume().getEndOffset();
+ }
setRange(ctorInitializer, offset, endOffset);
fdef.addMemberInitializer(ctorInitializer);
@@ -2753,36 +2836,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
- protected IASTInitializer initializerClause(boolean inAggregateInitializer) throws EndOfFileException,
+ protected ICPPASTInitializer initializerClause(boolean inAggregateInitializer) throws EndOfFileException,
BacktrackException {
if (LT(1) == IToken.tLBRACE) {
- int startingOffset = consume().getOffset();
-
- IASTInitializerList result = nodeFactory.newInitializerList();
- ((ASTNode) result).setOffset(startingOffset);
-
- if (LT(1) == (IToken.tRBRACE)) {
- int endOffset = consume().getEndOffset();
- setRange(result, startingOffset, endOffset);
- return result;
- }
-
- // otherwise it is a list of initializer clauses
- for (;;) {
- if (LT(1) == IToken.tRBRACE)
- break;
-
- // clause may be null, add to initializer anyways, such that the
- // actual size can be computed.
- IASTInitializer clause = initializerClause(true);
- result.addInitializer(clause);
- if (LT(1) == IToken.tRBRACE || LT(1) == IToken.tEOC)
- break;
- consume(IToken.tCOMMA);
- }
- int endOffset = consume().getEndOffset(); // tRBRACE
- setRange(result, startingOffset, endOffset);
- return result;
+ return initializerList();
}
// no brace, so try an assignment expression
@@ -2793,14 +2850,38 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return null;
}
- IASTInitializerExpression result = nodeFactory.newInitializerExpression(assignmentExpression);
+ ICPPASTInitializerExpression result = nodeFactory.newInitializerExpression(assignmentExpression);
setRange(result, assignmentExpression);
return result;
}
+ private ICPPASTInitializerList initializerList() throws EndOfFileException, BacktrackException {
+ int startingOffset = consume(IToken.tLBRACE).getOffset();
+
+ ICPPASTInitializerList result = nodeFactory.newInitializerList();
+
+ // List of initializer clauses
+ while (LT(1) != IToken.tRBRACE && LT(1) != IToken.tEOC) {
+ // Clause may be null, add to initializer anyways, such that the
+ // actual size can be computed.
+ ICPPASTInitializer clause = initializerClause(true);
+ if (LT(1) == IToken.tELLIPSIS) {
+ clause.setIsPackExpansion(true);
+ adjustEndOffset(clause, consume().getEndOffset());
+ }
+ result.addInitializer(clause);
+ if (LT(1) == IToken.tRBRACE || LT(1) == IToken.tEOC)
+ break;
+ consume(IToken.tCOMMA); // Allow for trailing commas
+ }
+ int endOffset = consume().getEndOffset(); // tRBRACE
+ setRange(result, startingOffset, endOffset);
+ return result;
+ }
+
@Override
- protected IASTTypeId typeId(DeclarationOptions option) throws EndOfFileException {
+ protected ICPPASTTypeId typeId(DeclarationOptions option) throws EndOfFileException {
if (!canBeTypeSpecifier()) {
return null;
}
@@ -2818,7 +2899,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
} catch (BacktrackException bt) {
return null;
}
- IASTTypeId result = nodeFactory.newTypeId(declSpecifier, declarator);
+ ICPPASTTypeId result = nodeFactory.newTypeId(declSpecifier, declarator);
setRange(result, offset, figureEndOffset(declSpecifier, declarator));
return result;
@@ -2845,9 +2926,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
final int startingOffset = LA(1).getOffset();
int endOffset = startingOffset;
- List<IASTPointerOperator> pointerOps = new ArrayList<IASTPointerOperator>(DEFAULT_POINTEROPS_LIST_SIZE);
- consumePointerOperators(pointerOps);
- if (!pointerOps.isEmpty()) {
+ List<? extends IASTPointerOperator> pointerOps = consumePointerOperators();
+ if (pointerOps != null) {
endOffset = calculateEndOffset(pointerOps.get(pointerOps.size() - 1));
}
@@ -2855,6 +2935,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
__attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
// Look for identifier or nested declarator
+ boolean hasEllipsis= false;
+ if (option.fAllowParameterPacks && LT(1) == IToken.tELLIPSIS) {
+ consume();
+ hasEllipsis= true;
+ }
final int lt1= LT(1);
switch (lt1) {
case IToken.tBITCOMPLEMENT:
@@ -2867,7 +2952,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
final IASTName declaratorName= qualifiedName(CastExprCtx.eNotBExpr);
endOffset= calculateEndOffset(declaratorName);
- return declarator(pointerOps, declaratorName, null, startingOffset, endOffset, strategy, option);
+ return declarator(pointerOps, hasEllipsis, declaratorName, null, startingOffset, endOffset, strategy, option);
}
if (lt1 == IToken.tLPAREN) {
@@ -2877,8 +2962,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (option.fAllowAbstract && option.fAllowFunctions) {
final IToken mark= mark();
try {
- cand1= declarator(pointerOps, nodeFactory.newName(), null, startingOffset, endOffset, strategy, option);
- if (option.fRequireAbstract || !option.fAllowNested)
+ cand1= declarator(pointerOps, hasEllipsis, nodeFactory.newName(), null, startingOffset, endOffset, strategy, option);
+ if (option.fRequireAbstract || !option.fAllowNested || hasEllipsis)
return cand1;
cand1End= LA(1);
@@ -2888,9 +2973,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
// type-ids for new or operator-id:
- if (!option.fAllowNested) {
+ if (!option.fAllowNested || hasEllipsis) {
if (option.fAllowAbstract) {
- return declarator(pointerOps, nodeFactory.newName(), null, startingOffset, endOffset, strategy, option);
+ return declarator(pointerOps, hasEllipsis, nodeFactory.newName(), null, startingOffset, endOffset, strategy, option);
}
throwBacktrack(LA(1));
}
@@ -2903,7 +2988,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
final IASTDeclarator nested= declarator(DtorStrategy.PREFER_FUNCTION, option);
endOffset= consume(IToken.tRPAREN).getEndOffset();
- final IASTDeclarator cand2= declarator(pointerOps, null, nested, startingOffset, endOffset, strategy, option);
+ final IASTDeclarator cand2= declarator(pointerOps, hasEllipsis, nodeFactory.newName(), nested, startingOffset, endOffset, strategy, option);
if (cand1 == null || cand1End == null)
return cand2;
final IToken cand2End= LA(1);
@@ -2930,7 +3015,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (!option.fAllowBitField || LT(1) != IToken.tCOLON)
throwBacktrack(LA(1));
}
- return declarator(pointerOps, nodeFactory.newName(), null, startingOffset, endOffset, strategy, option);
+ return declarator(pointerOps, hasEllipsis, nodeFactory.newName(), null, startingOffset, endOffset, strategy, option);
}
/**
@@ -2940,9 +3025,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* @throws BacktrackException
* request a backtrack
*/
- private void consumePointerOperators(List<IASTPointerOperator> collection)
- throws EndOfFileException, BacktrackException {
-
+ private List<? extends IASTPointerOperator> consumePointerOperators() throws EndOfFileException, BacktrackException {
+ List<IASTPointerOperator> result= null;
for (;;) {
// __attribute__ in-between pointers
__attribute_decl_seq(supportAttributeSpecifiers, false);
@@ -2956,8 +3040,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
endToken= consume();
}
ICPPASTReferenceOperator refOp = nodeFactory.newReferenceOperator(lt1 == IToken.tAND);
- collection.add(setRange(refOp, offset, endToken.getEndOffset()));
- return;
+ setRange(refOp, offset, endToken.getEndOffset());
+ if (result != null) {
+ result.add(refOp);
+ return result;
+ }
+ return Collections.singletonList(refOp);
}
IToken mark = mark();
@@ -2983,16 +3071,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
name= qualifiedName(CastExprCtx.eNotBExpr);
if (name.getLookupKey().length != 0) {
backup(mark);
- return;
+ return result;
}
} catch (BacktrackException bt) {
backup(mark);
- return;
+ return result;
}
}
if (LTcatchEOF(1) != IToken.tSTAR) {
backup(mark);
- return;
+ return result;
}
int endOffset= consume().getEndOffset();
@@ -3039,28 +3127,31 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
pointer.setConst(isConst);
pointer.setVolatile(isVolatile);
setRange(pointer, startOffset, endOffset);
- collection.add(pointer);
+ if (result == null) {
+ result= new ArrayList<IASTPointerOperator>(4);
+ }
+ result.add(pointer);
}
}
- private IASTDeclarator declarator(List<IASTPointerOperator> pointerOps,
+ private IASTDeclarator declarator(List<? extends IASTPointerOperator> pointerOps, boolean hasEllipsis,
IASTName declaratorName, IASTDeclarator nestedDeclarator, int startingOffset, int endOffset,
DtorStrategy strategy, DeclarationOptions option)
throws EndOfFileException, BacktrackException {
- IASTDeclarator result= null;
+ ICPPASTDeclarator result= null;
loop: while(true) {
final int lt1= LTcatchEOF(1);
switch (lt1) {
case IToken.tLPAREN:
if (option.fAllowFunctions && strategy == DtorStrategy.PREFER_FUNCTION) {
result= functionDeclarator();
- setDeclaratorID(result, declaratorName, nestedDeclarator);
+ setDeclaratorID(result, hasEllipsis, declaratorName, nestedDeclarator);
}
break loop;
case IToken.tLBRACKET:
result= arrayDeclarator(option);
- setDeclaratorID(result, declaratorName, nestedDeclarator);
+ setDeclaratorID(result, hasEllipsis, declaratorName, nestedDeclarator);
break loop;
case IToken.tCOLON:
@@ -3068,7 +3159,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
break loop; // no backtrack because typeid can be followed by colon
result= bitFieldDeclarator();
- setDeclaratorID(result, declaratorName, nestedDeclarator);
+ setDeclaratorID(result, hasEllipsis, declaratorName, nestedDeclarator);
break loop;
case IGCCToken.t__attribute__: // if __attribute__ is after a declarator
@@ -3089,7 +3180,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (result == null) {
result= nodeFactory.newDeclarator(null);
- setDeclaratorID(result, declaratorName, nestedDeclarator);
+ setDeclaratorID(result, hasEllipsis, declaratorName, nestedDeclarator);
} else {
endOffset= calculateEndOffset(result);
}
@@ -3101,33 +3192,36 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
__attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
}
- for (IASTPointerOperator po : pointerOps) {
- result.addPointerOperator(po);
- }
+ if (pointerOps != null) {
+ for (IASTPointerOperator po : pointerOps) {
+ result.addPointerOperator(po);
+ }
+ }
((ASTNode) result).setOffsetAndLength(startingOffset, endOffset - startingOffset);
return result;
}
- private void setDeclaratorID(IASTDeclarator declarator, IASTName declaratorName, IASTDeclarator nestedDeclarator) {
+ private void setDeclaratorID(ICPPASTDeclarator declarator, boolean hasEllipsis, IASTName declaratorName, IASTDeclarator nestedDeclarator) {
if (nestedDeclarator != null) {
declarator.setNestedDeclarator(nestedDeclarator);
declarator.setName(nodeFactory.newName());
} else {
declarator.setName(declaratorName);
}
+ declarator.setDeclaresParameterPack(hasEllipsis);
}
/**
* Parse a function declarator starting with the left parenthesis.
*/
- private IASTDeclarator functionDeclarator() throws EndOfFileException, BacktrackException {
+ private ICPPASTDeclarator functionDeclarator() throws EndOfFileException, BacktrackException {
IToken last = consume(IToken.tLPAREN);
int startOffset= last.getOffset();
- boolean seenParameter= false;
int endOffset= last.getEndOffset();
final ICPPASTFunctionDeclarator fc = nodeFactory.newFunctionDeclarator(null);
+ ICPPASTParameterDeclaration pd= null;
paramLoop: while(true) {
switch (LT(1)) {
case IToken.tRPAREN:
@@ -3135,24 +3229,36 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
endOffset= consume().getEndOffset();
break paramLoop;
case IToken.tELLIPSIS:
- endOffset= consume().getEndOffset();
+ consume();
+ endOffset= consume(IToken.tRPAREN).getEndOffset();
fc.setVarArgs(true);
- break;
+ break paramLoop;
case IToken.tCOMMA:
+ if (pd == null)
+ throwBacktrack(LA(1));
endOffset= consume().getEndOffset();
- seenParameter = false;
+ pd= null;
break;
default:
- if (seenParameter)
+ if (pd != null)
throwBacktrack(startOffset, endOffset - startOffset);
- IASTParameterDeclaration pd = parameterDeclaration();
+ pd = parameterDeclaration();
fc.addParameterDeclaration(pd);
endOffset = calculateEndOffset(pd);
- seenParameter = true;
break;
}
}
+ // Handle ambiguity between parameter pack and varargs.
+ if (pd != null) {
+ ICPPASTDeclarator dtor = pd.getDeclarator();
+ if (!(dtor instanceof IASTAmbiguousDeclarator)) {
+ if (dtor.declaresParameterPack() && dtor.getNestedDeclarator() == null
+ && dtor.getInitializer() == null && dtor.getName().getSimpleID().length == 0) {
+ ((IASTAmbiguityParent) fc).replace(pd, new CPPASTAmbiguousParameterDeclaration(pd));
+ }
+ }
+ }
// Consume any number of __attribute__ tokens after the parameters
__attribute_decl_seq(supportAttributeSpecifiers, false);
@@ -3190,8 +3296,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
break;
default:
int thoffset = LA(1).getOffset();
- IASTTypeId typeId = typeId(DeclarationOptions.TYPEID);
+ ICPPASTTypeId typeId = typeId(DeclarationOptions.TYPEID);
if (typeId != null) {
+ if (LT(1) == IToken.tELLIPSIS) {
+ typeId.setIsPackExpansion(true);
+ adjustEndOffset(typeId, consume().getEndOffset());
+ }
fc.addExceptionSpecificationTypeId(typeId);
} else {
int thendoffset = LA(1).getOffset();
@@ -3218,15 +3328,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
/**
* Parse an array declarator starting at the square bracket.
*/
- private IASTArrayDeclarator arrayDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
- ArrayList<IASTArrayModifier> arrayMods = new ArrayList<IASTArrayModifier>(DEFAULT_POINTEROPS_LIST_SIZE);
+ private ICPPASTArrayDeclarator arrayDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
+ ArrayList<IASTArrayModifier> arrayMods = new ArrayList<IASTArrayModifier>(4);
int start= LA(1).getOffset();
consumeArrayModifiers(option, arrayMods);
if (arrayMods.isEmpty())
throwBacktrack(LA(1));
final int endOffset = calculateEndOffset(arrayMods.get(arrayMods.size() - 1));
- final IASTArrayDeclarator d = nodeFactory.newArrayDeclarator(null);
+ final ICPPASTArrayDeclarator d = nodeFactory.newArrayDeclarator(null);
for (IASTArrayModifier m : arrayMods) {
d.addArrayModifier(m);
}
@@ -3239,13 +3349,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
/**
* Parses for a bit field declarator starting with the colon
*/
- private IASTFieldDeclarator bitFieldDeclarator() throws EndOfFileException, BacktrackException {
+ private ICPPASTFieldDeclarator bitFieldDeclarator() throws EndOfFileException, BacktrackException {
int start= consume(IToken.tCOLON).getOffset();
final IASTExpression bitField = constantExpression();
final int endOffset = calculateEndOffset(bitField);
- IASTFieldDeclarator d = nodeFactory.newFieldDeclarator(null, bitField);
+ ICPPASTFieldDeclarator d = nodeFactory.newFieldDeclarator(null, bitField);
((ASTNode) d).setOffsetAndLength(start, endOffset-start);
return d;
}
@@ -3298,7 +3408,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
// base clause
if (LT(1) == IToken.tCOLON) {
- baseSpecifier(astClassSpecifier);
+ baseClause(astClassSpecifier);
// content assist within the base-clause
if (LT(1) == IToken.tEOC) {
return astClassSpecifier;
@@ -3335,76 +3445,74 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
/**
- * Parse the subclass-baseclauses for a class specification. baseclause: :
- * basespecifierlist basespecifierlist: basespecifier basespecifierlist,
- * basespecifier basespecifier: ::? nestednamespecifier? classname virtual
- * accessspecifier? ::? nestednamespecifier? classname accessspecifier
- * virtual? ::? nestednamespecifier? classname accessspecifier: private |
- * protected | public
- *
- * @throws BacktrackException
+ * Parse a base clause for a class specification.
+ * base-clause:
+ * : base-specifier-list
+ * base-specifier-list:
+ * base-specifier
+ * base-specifier-list, base-specifier
*/
- protected void baseSpecifier(ICPPASTCompositeTypeSpecifier astClassSpec) throws EndOfFileException, BacktrackException {
- int endOffset= consume().getEndOffset(); // tCOLON
+ private void baseClause(ICPPASTCompositeTypeSpecifier astClassSpec) throws EndOfFileException, BacktrackException {
+ consume(IToken.tCOLON);
+ for (;;) {
+ ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier baseSpec = baseSpecifier();
+ astClassSpec.addBaseSpecifier(baseSpec);
+
+ if (LT(1) == IToken.tELLIPSIS) {
+ baseSpec.setIsPackExpansion(true);
+ adjustEndOffset(baseSpec, consume().getEndOffset());
+ }
+
+ if (LT(1) != IToken.tCOMMA) {
+ return;
+ }
+
+ consume();
+ }
+ }
+
+ /**
+ * base-specifier:
+ * ::? nested-name-specifier? class-name
+ * virtual access-specifier? ::? nested-name-specifier? class-name
+ * access-specifier virtual? ::? nested-name-specifier? class-name
+ *
+ * access-specifier: private | protected | public
+ * @return
+ */
+ private ICPPASTBaseSpecifier baseSpecifier() throws EndOfFileException, BacktrackException {
int startOffset= LA(1).getOffset();
-
boolean isVirtual = false;
int visibility = 0;
IASTName name = null;
- baseSpecifierLoop: for (;;) {
+ loop: for (;;) {
switch (LT(1)) {
case IToken.t_virtual:
isVirtual = true;
- endOffset= consume().getEndOffset();
+ consume();
break;
case IToken.t_public:
visibility = ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.v_public;
- endOffset= consume().getEndOffset();
+ consume();
break;
case IToken.t_protected:
visibility = ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.v_protected;
- endOffset= consume().getEndOffset();
+ consume();
break;
case IToken.t_private:
visibility = ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.v_private;
- endOffset= consume().getEndOffset();
- break;
- case IToken.tCOLONCOLON:
- case IToken.tIDENTIFIER:
- case IToken.tCOMPLETION:
- // to get templates right we need to use the class as the scope
- name = qualifiedName(CastExprCtx.eNotBExpr);
- endOffset= calculateEndOffset(name);
+ consume();
break;
- case IToken.tCOMMA:
- if (name == null)
- name = nodeFactory.newName();
- consume();
- ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier baseSpec = nodeFactory.newBaseSpecifier(name, visibility, isVirtual);
- setRange(baseSpec, startOffset, endOffset);
- astClassSpec.addBaseSpecifier(baseSpec);
-
- isVirtual = false;
- visibility = 0;
- name = null;
- startOffset= endOffset= LA(1).getOffset();
- continue baseSpecifierLoop;
- case IToken.tLBRACE:
- case IToken.tEOC:
- if (name == null)
- name = nodeFactory.newName();
- baseSpec = nodeFactory.newBaseSpecifier(name, visibility, isVirtual);
- setRange(baseSpec, startOffset, endOffset);
- astClassSpec.addBaseSpecifier(baseSpec);
- break baseSpecifierLoop;
-
default:
- break baseSpecifierLoop;
+ break loop;
}
}
+ name = qualifiedName(CastExprCtx.eNotBExpr);
+ ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier baseSpec = nodeFactory.newBaseSpecifier(name, visibility, isVirtual);
+ setRange(baseSpec, startOffset, calculateEndOffset(name));
+ return baseSpec;
}
-
protected void catchHandlerSequence(List<ICPPASTCatchHandler> collection) throws EndOfFileException, BacktrackException {
if (LT(1) == IToken.tEOC)
return;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index 4eb506bbdfa..f6231e4ee3e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -65,14 +65,12 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdInitializerExpression;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
-import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
-import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
@@ -87,6 +85,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
@@ -106,6 +105,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
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.ICPPASTWhileStatement;
@@ -446,6 +446,9 @@ public class CPPSemantics {
IASTNode parent= name.getParent().getParent();
if (parent instanceof ICPPASTTemplatedTypeTemplateParameter) {
// default for template template parameter is an id-expression, which is a type.
+ } else if (parent instanceof ICPPASTUnaryExpression
+ && ((ICPPASTUnaryExpression) parent).getOperator() == IASTUnaryExpression.op_sizeofParameterPack) {
+ // argument of sizeof... can be a type
} else if (data.considerConstructors &&
(binding instanceof ICPPUnknownType || binding instanceof ITypedef || binding instanceof IEnumeration)) {
// constructor or simple-type constructor
@@ -959,6 +962,7 @@ public class CPPSemantics {
if (expression instanceof IASTUnaryExpression) {
switch (((IASTUnaryExpression) expression).getOperator()) {
case IASTUnaryExpression.op_sizeof:
+ case IASTUnaryExpression.op_sizeofParameterPack:
case IASTUnaryExpression.op_typeid:
case IASTUnaryExpression.op_throw:
return PROCESS_SKIP;
@@ -1949,25 +1953,23 @@ public class CPPSemantics {
if (def && argumentCount == 1) {
// check for parameter of type void
final IType[] argTypes = data.getFunctionArgumentTypes();
- if (argTypes.length == 1) {
- IType t= getNestedType(argTypes[0], TDEF);
- if (t instanceof IBasicType && ((IBasicType)t).getKind() == Kind.eVoid) {
- argumentCount= 0;
- }
+ if (argTypes.length == 1 && SemanticUtil.isVoidType(argTypes[0])) {
+ argumentCount= 0;
}
}
// Trim the list down to the set of viable functions
- IFunction function = null;
+ ICPPFunction function = null;
int size = functions.length;
for (int i = 0; i < size; i++) {
- function = (IFunction) functions[i];
- if (function == null)
- continue;
- if (function instanceof IProblemBinding) {
+ if (functions[i] instanceof IProblemBinding) {
functions[i]= null;
continue;
}
+
+ function = (ICPPFunction) functions[i];
+ if (function == null)
+ continue;
if (function instanceof ICPPUnknownBinding) {
if (def) {
functions[i]= null;
@@ -1979,47 +1981,31 @@ public class CPPSemantics {
// as long as possible.
final IType[] parameterTypes = function.getType().getParameterTypes();
int numPars = parameterTypes.length;
+ if (numPars == 1 && SemanticUtil.isVoidType(parameterTypes[0]))
+ numPars= 0;
int numArgs = argumentCount;
if (function instanceof ICPPMethod && data.firstArgIsImpliedMethodArg)
numArgs--;
- if (numArgs < 2 && numPars == 1) {
- // check for void
- IType t = getNestedType(parameterTypes[0], TDEF);
- if (t instanceof IBasicType && ((IBasicType)t).getKind() == Kind.eVoid)
- numPars= 0;
- }
-
if (def) {
if (numPars != numArgs || !isMatchingFunctionDeclaration(function, data)) {
functions[i] = null;
}
} else {
- // more arguments than parameters --> need ellipses
+ // more arguments than parameters --> need ellipsis
if (numArgs > numPars) {
- if (!function.takesVarArgs()) {
+ if (!function.takesVarArgs() && !function.hasParameterPack()) {
functions[i] = null;
}
- } else if (numArgs < numPars) {
- // fewer arguments than parameters --> need default values
- IParameter[] params = function.getParameters();
- if (params.length < numPars) {
- functions[i]= null;
- } else {
- for (int j = numArgs; j < numPars; j++) {
- final ICPPParameter param = (ICPPParameter) params[j];
- if (param == null || !param.hasDefaultValue()) {
- functions[i] = null;
- break;
- }
- }
- }
+ } else if (numArgs < function.getRequiredArgumentCount()) {
+ // fewer arguments than required
+ functions[i]= null;
}
}
}
}
- static private boolean isMatchingFunctionDeclaration(IFunction candidate, LookupData data) {
+ static private boolean isMatchingFunctionDeclaration(ICPPFunction candidate, LookupData data) {
IASTNode node = data.astName.getParent();
while (node instanceof IASTName)
node = node.getParent();
@@ -3039,8 +3025,9 @@ public class CPPSemantics {
return set.keyArray(IBinding.class);
}
- public static boolean isSameFunction(IFunction function, IASTDeclarator declarator) {
- IASTName name = ASTQueries.findInnermostDeclarator(declarator).getName();
+ public static boolean isSameFunction(ICPPFunction function, IASTDeclarator declarator) {
+ final ICPPASTDeclarator innerDtor = (ICPPASTDeclarator) ASTQueries.findInnermostDeclarator(declarator);
+ IASTName name = innerDtor.getName();
ICPPASTTemplateDeclaration templateDecl = CPPTemplates.getTemplateDeclaration(name);
if (templateDecl != null) {
if (templateDecl instanceof ICPPASTTemplateSpecialization) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
index dd0bd9c3224..28f111e42b8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
@@ -74,6 +74,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
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.ICPPScope;
@@ -119,6 +120,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodTemplateSpecialization;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
@@ -400,8 +402,13 @@ public class CPPTemplates {
for (int i = 0; i < templateParameters.length; i++) {
final ICPPTemplateParameter tp = templateParameters[i];
if (tp instanceof IType) {
- args[i] = new CPPTemplateArgument((IType) tp);
+ IType t= (IType) tp;
+ if (tp.isParameterPack()) {
+ t= new CPPParameterPackType(t);
+ }
+ args[i] = new CPPTemplateArgument(t);
} else if (tp instanceof ICPPTemplateNonTypeParameter) {
+ // Non-type template parameter pack already has type 'ICPPParameterPackType'
final ICPPTemplateNonTypeParameter nttp = (ICPPTemplateNonTypeParameter) tp;
args[i] = new CPPTemplateArgument(Value.create(nttp), nttp.getType());
} else {
@@ -490,15 +497,15 @@ public class CPPTemplates {
return (binding instanceof ICPPTemplateDefinition) ? (ICPPTemplateDefinition) binding : null;
}
- public static IBinding createBinding(ICPPASTTemplateParameter templateParameter) {
- if (templateParameter instanceof ICPPASTSimpleTypeTemplateParameter) {
- return new CPPTemplateTypeParameter(((ICPPASTSimpleTypeTemplateParameter) templateParameter).getName());
+ public static IBinding createBinding(ICPPASTTemplateParameter tp) {
+ if (tp instanceof ICPPASTSimpleTypeTemplateParameter) {
+ return new CPPTemplateTypeParameter(((ICPPASTSimpleTypeTemplateParameter) tp).getName(), tp.isParameterPack());
}
- if (templateParameter instanceof ICPPASTTemplatedTypeTemplateParameter) {
- return new CPPTemplateTemplateParameter(((ICPPASTTemplatedTypeTemplateParameter) templateParameter).getName());
+ if (tp instanceof ICPPASTTemplatedTypeTemplateParameter) {
+ return new CPPTemplateTemplateParameter(((ICPPASTTemplatedTypeTemplateParameter) tp).getName(), tp.isParameterPack());
}
- assert templateParameter instanceof ICPPASTParameterDeclaration;
- final IASTDeclarator dtor = ((ICPPASTParameterDeclaration) templateParameter).getDeclarator();
+ assert tp instanceof ICPPASTParameterDeclaration;
+ final IASTDeclarator dtor = ((ICPPASTParameterDeclaration) tp).getDeclarator();
return new CPPTemplateNonTypeParameter(ASTQueries.findInnermostDeclarator(dtor).getName());
}
@@ -708,15 +715,15 @@ public class CPPTemplates {
ICPPTemplateInstance instance = null;
if (template instanceof ICPPClassType) {
- instance = new CPPClassInstance(owner, (ICPPClassType) template, tpMap, args);
+ instance = new CPPClassInstance((ICPPClassType) template, owner, tpMap, args);
} else if (owner instanceof ICPPClassType && template instanceof ICPPMethod) {
if (template instanceof ICPPConstructor) {
- instance = new CPPConstructorInstance((ICPPClassType) owner, (ICPPConstructor) template, tpMap, args);
+ instance = new CPPConstructorInstance((ICPPConstructor) template, (ICPPClassType) owner, tpMap, args);
} else {
- instance = new CPPMethodInstance((ICPPClassType) owner, (ICPPMethod) template, tpMap, args);
+ instance = new CPPMethodInstance((ICPPMethod) template, (ICPPClassType) owner, tpMap, args);
}
} else if (template instanceof ICPPFunction) {
- instance = new CPPFunctionInstance(owner, (ICPPFunction) template, tpMap, args);
+ instance = new CPPFunctionInstance((ICPPFunction) template, owner, tpMap, args);
}
return instance;
}
@@ -739,17 +746,17 @@ public class CPPTemplates {
spec = new CPPFieldSpecialization(decl, owner, tpMap);
} else if (decl instanceof ICPPFunctionTemplate) {
if (decl instanceof ICPPConstructor)
- spec = new CPPConstructorTemplateSpecialization(decl, owner, tpMap);
+ spec = new CPPConstructorTemplateSpecialization((ICPPConstructor) decl, owner, tpMap);
else if (decl instanceof ICPPMethod)
- spec = new CPPMethodTemplateSpecialization(decl, owner, tpMap);
+ spec = new CPPMethodTemplateSpecialization((ICPPMethod) decl, owner, tpMap);
else
- spec = new CPPFunctionTemplateSpecialization(decl, owner, tpMap);
+ spec = new CPPFunctionTemplateSpecialization((ICPPFunctionTemplate) decl, owner, tpMap);
} else if (decl instanceof ICPPConstructor) {
- spec = new CPPConstructorSpecialization(decl, owner, tpMap);
+ spec = new CPPConstructorSpecialization((ICPPConstructor) decl, owner, tpMap);
} else if (decl instanceof ICPPMethod) {
- spec = new CPPMethodSpecialization(decl, owner, tpMap);
+ spec = new CPPMethodSpecialization((ICPPMethod) decl, owner, tpMap);
} else if (decl instanceof ICPPFunction) {
- spec = new CPPFunctionSpecialization(decl, owner, tpMap);
+ spec = new CPPFunctionSpecialization((ICPPFunction) decl, owner, tpMap);
} else if (decl instanceof ITypedef) {
spec = new CPPTypedefSpecialization(decl, owner, tpMap);
} else if (decl instanceof IEnumeration || decl instanceof IEnumerator) {
@@ -815,7 +822,7 @@ public class CPPTemplates {
if (ret == r && params == ps) {
return type;
}
- return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile());
+ return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
}
if (type instanceof ICPPTemplateParameter) {
@@ -2105,7 +2112,16 @@ public class CPPTemplates {
if (arg.isNonTypeValue())
return false;
IType argType= arg.getTypeValue();
- if (argType == null || !argType.isSameType((IType) par))
+ if (argType == null)
+ return false;
+ if (par.isParameterPack()) {
+ if (!(argType instanceof ICPPParameterPackType))
+ return false;
+ argType= ((ICPPParameterPackType) argType).getType();
+ if (argType == null)
+ return false;
+ }
+ if (!argType.isSameType((IType) par))
return false;
} else {
if (arg.isTypeValue())
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
index a0f33b20967..980727da09a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
@@ -13,9 +13,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
-import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
-import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType;
-import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
+import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.DOMException;
@@ -66,7 +64,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
-import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IParameter;
@@ -84,6 +81,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
@@ -106,6 +104,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
@@ -157,6 +156,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodTemplate;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNamespace;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNamespaceAlias;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameter;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
@@ -556,7 +556,7 @@ public class CPPVisitor extends ASTQueries {
parent = param.getParent();
if (parent instanceof IASTStandardFunctionDeclarator) {
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) param.getParent();
- // if the fdtor does not declare a function we don't create a binding for the parameter.
+ // Create parameter bindings only if the declarator declares a function
if (!(findOutermostDeclarator(fdtor).getParent() instanceof IASTDeclaration) ||
findTypeRelevantDeclarator(fdtor) != fdtor)
return null;
@@ -660,8 +660,8 @@ public class CPPVisitor extends ASTQueries {
}
if (isFunction) {
- if (binding instanceof ICPPInternalBinding && binding instanceof IFunction && name.isActive()) {
- IFunction function = (IFunction) binding;
+ if (binding instanceof ICPPInternalBinding && binding instanceof ICPPFunction && name.isActive()) {
+ ICPPFunction function = (ICPPFunction) binding;
if (CPPSemantics.isSameFunction(function, typeRelevantDtor)) {
binding= CPPSemantics.checkDeclSpecifier(binding, name, parent);
if (binding instanceof IProblemBinding)
@@ -1547,22 +1547,14 @@ public class CPPVisitor extends ASTQueries {
pTypes[i] = pt;
}
- return new CPPFunctionType(returnType, pTypes, isConst, isVolatile);
+ return new CPPFunctionType(returnType, pTypes, isConst, isVolatile, false);
}
private static IType createType(IType returnType, ICPPASTFunctionDeclarator fnDtor) {
- IASTParameterDeclaration[] params = fnDtor.getParameters();
+ ICPPASTParameterDeclaration[] params = fnDtor.getParameters();
IType[] pTypes = new IType[params.length];
- IType pt = null;
-
for (int i = 0; i < params.length; i++) {
- IASTDeclSpecifier pDeclSpec = params[i].getDeclSpecifier();
- IASTDeclarator pDtor = params[i].getDeclarator();
- pt = createType(pDeclSpec);
- pt = createType(pt, pDtor);
-
- pt = SemanticUtil.adjustParameterType(pt, true);
- pTypes[i] = pt;
+ pTypes[i]= createParameterType(params[i], true);
}
IASTName name = fnDtor.getName();
@@ -1576,13 +1568,55 @@ public class CPPVisitor extends ASTQueries {
returnType = getPointerTypes(returnType, fnDtor);
}
- IType type = new CPPFunctionType(returnType, pTypes, fnDtor.isConst(), fnDtor.isVolatile());
+ CPPFunctionType type = new CPPFunctionType(returnType, pTypes, fnDtor.isConst(), fnDtor.isVolatile(),
+ fnDtor.takesVarArgs());
final IASTDeclarator nested = fnDtor.getNestedDeclarator();
if (nested != null) {
return createType(type, nested);
}
return type;
}
+
+ /**
+ * Creates the type for a parameter declaration.
+ */
+ public static IType createParameterType(final ICPPASTParameterDeclaration pdecl, boolean forFuncType) {
+ IType pt;
+ IASTDeclSpecifier pDeclSpec = pdecl.getDeclSpecifier();
+ ICPPASTDeclarator pDtor = pdecl.getDeclarator();
+ pt = createType(pDeclSpec);
+ pt = createType(pt, pDtor);
+ pt= adjustParameterType(pt, forFuncType);
+
+ if (CPPVisitor.findInnermostDeclarator(pDtor).declaresParameterPack()) {
+ pt= new CPPParameterPackType(pt);
+ }
+ return pt;
+ }
+
+ /**
+ * Adjusts the parameter type according to 8.3.5-3:
+ * cv-qualifiers are deleted, arrays and function types are converted to pointers.
+ */
+ private static IType adjustParameterType(final IType pt, boolean forFunctionType) {
+ // bug 239975
+ IType t= SemanticUtil.getNestedType(pt, TDEF);
+ if (t instanceof IArrayType) {
+ IArrayType at = (IArrayType) t;
+ return new CPPPointerType(at.getType());
+ }
+ if (t instanceof IFunctionType) {
+ return new CPPPointerType(pt);
+ }
+
+ // 8.3.5-3
+ // Any cv-qualifier modifying a parameter type is deleted. The parameter type remains
+ // to be qualified.
+ if (forFunctionType && SemanticUtil.getCVQualifier(t) != CVQualifier._) {
+ return SemanticUtil.getNestedType(t, TDEF | ALLCVQ);
+ }
+ return pt;
+ }
/**
* @param declarator
@@ -1652,14 +1686,18 @@ public class CPPVisitor extends ASTQueries {
IASTNode parent = declarator.getParent();
IASTDeclSpecifier declSpec = null;
- if (parent instanceof IASTParameterDeclaration) {
- declSpec = ((IASTParameterDeclaration) parent).getDeclSpecifier();
- } else if (parent instanceof IASTSimpleDeclaration) {
+ boolean isPackExpansion= false;
+ if (parent instanceof IASTSimpleDeclaration) {
declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier();
} else if (parent instanceof IASTFunctionDefinition) {
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
- } else if (parent instanceof IASTTypeId) {
- declSpec = ((IASTTypeId)parent).getDeclSpecifier();
+ } else if (parent instanceof ICPPASTTypeId) {
+ final ICPPASTTypeId typeId = (ICPPASTTypeId)parent;
+ declSpec = typeId.getDeclSpecifier();
+ isPackExpansion= typeId.isPackExpansion();
+ } else {
+ assert false;
+ return null;
}
IType type = createType(declSpec);
@@ -1676,6 +1714,9 @@ public class CPPVisitor extends ASTQueries {
}
}
}
+ if (isPackExpansion) {
+ type= new CPPParameterPackType(type);
+ }
return type;
}
@@ -2154,4 +2195,8 @@ public class CPPVisitor extends ASTQueries {
}
return false;
}
+
+ public static ICPPASTDeclarator findInnermostDeclarator(ICPPASTDeclarator dtor) {
+ return (ICPPASTDeclarator) ASTQueries.findInnermostDeclarator(dtor);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java
index f84916440a5..e6b580662fd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java
@@ -27,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
-import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
@@ -40,7 +39,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
@@ -136,13 +134,7 @@ public class Conversions {
// shall be an rvalue.
boolean ok;
if (isLValueRef) {
- // mstodo
- // Special rule for implicit object type, 13.3.1-5:
- // Even if the implicit object type is not const-qualified, an rvalue temporary can
- // be bound to the parameter as long as in all other respects ....
- //
- final CVQualifier cvq = getCVQualifier(cv1T1);
- ok = cvq == CVQualifier.c;
+ ok = getCVQualifier(cv1T1) == CVQualifier.c;
} else {
ok= !exprIsLValue;
}
@@ -467,16 +459,13 @@ public class Conversions {
continue;
}
} else {
- IType ptype= ptypes[0];
+ IType ptype= SemanticUtil.getNestedType(ptypes[0], TDEF);
// We don't need to check the implicit conversion sequence if the type is void
- if (ptype instanceof ICPPBasicType && ((ICPPBasicType) ptype).getKind() == Kind.eVoid)
+ if (SemanticUtil.isVoidType(ptype))
continue;
- if (ptypes.length > 1) {
- IParameter[] pars = ctor.getParameters();
- if (pars.length < 2 || !((ICPPParameter) pars[1]).hasDefaultValue())
- continue;
-
- }
+ if (ctor.getRequiredArgumentCount() > 1)
+ continue;
+
c1= new FunctionCost(ctor, checkImplicitConversionSequence(ptype, source, sourceIsLValue, UDCMode.noUDC, false));
}
int cmp= c1.compareTo(null, cost1);
@@ -868,7 +857,7 @@ public class Conversions {
// 4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be
// converted to an rvalue of type "pointer to cv void"
IType tgtPtrTgt= getNestedType(tgtPtr.getType(), TDEF | CVTYPE | REF);
- if (tgtPtrTgt instanceof IBasicType && ((IBasicType) tgtPtrTgt).getKind() == Kind.eVoid) {
+ if (SemanticUtil.isVoidType(tgtPtrTgt)) {
cost.setRank(Rank.CONVERSION);
cost.setInheritanceDistance(Short.MAX_VALUE); // mstodo add distance to last base class
CVQualifier cv= getCVQualifier(srcPtr.getType());
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
index f5a54084b94..1311cbb2f77 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
@@ -36,7 +36,6 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
@@ -56,6 +55,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
@@ -598,12 +598,12 @@ public class LookupData {
public IType[] getFunctionArgumentTypes() {
if (functionArgTypes == null && functionArgs != null) {
- if (functionArgs instanceof IASTParameterDeclaration[]) {
- IASTParameterDeclaration[] pdecls= (IASTParameterDeclaration[]) functionArgs;
+ if (functionArgs instanceof ICPPASTParameterDeclaration[]) {
+ ICPPASTParameterDeclaration[] pdecls= (ICPPASTParameterDeclaration[]) functionArgs;
functionArgTypes= new IType[pdecls.length];
for (int i = 0; i < pdecls.length; i++) {
- IASTParameterDeclaration p = pdecls[i];
- functionArgTypes[i]= SemanticUtil.getSimplifiedType(CPPVisitor.createType(p.getDeclarator()));
+ functionArgTypes[i] = SemanticUtil.getSimplifiedType(CPPVisitor.createParameterType(
+ pdecls[i], true));
}
} else if (functionArgs instanceof IASTExpression[]) {
IASTExpression[] exprs= (IASTExpression[]) functionArgs;
@@ -647,7 +647,7 @@ public class LookupData {
functionArgTypes= paramTypes;
}
- public void setFunctionParameters(IASTParameterDeclaration[] parameters) {
+ public void setFunctionParameters(ICPPASTParameterDeclaration[] parameters) {
functionArgs= parameters;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
index 7fbb368181e..4bc27bba2e6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
@@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IArrayType;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IPointerType;
@@ -27,14 +28,17 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
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.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
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.ICPPTemplateArgument;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@@ -49,6 +53,7 @@ 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.CPPTemplateArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
/**
@@ -288,6 +293,7 @@ public class SemanticUtil {
return replaceNestedType((ITypeContainer) rt, newNested);
}
}
+ // Pack expansion types are dependent types, there is no need to descend into those.
if (t == null)
return type;
@@ -310,7 +316,7 @@ public class SemanticUtil {
if (ret == r && params == ps) {
return type;
}
- return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile());
+ return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
}
if (type instanceof ITypedef) {
@@ -371,6 +377,50 @@ public class SemanticUtil {
return type;
}
+ public static boolean containsParameterPack(IType type) {
+ while (true) {
+ if (type instanceof ICPPTemplateParameter) {
+ return ((ICPPTemplateParameter) type).isParameterPack();
+ } else if (type instanceof ICPPDeferredClassInstance) {
+ // mstodo check the deferred arguments.
+ return false;
+ } else if (type instanceof ICPPUnknownBinding) {
+ try {
+ IBinding owner= ((ICPPUnknownBinding) type).getOwner();
+ if (owner instanceof IType) {
+ type= (IType) owner;
+ } else {
+ return false;
+ }
+ } catch (DOMException e) {
+ return false;
+ }
+ } else if (type instanceof IFunctionType) {
+ final ICPPFunctionType ft = (ICPPFunctionType) type;
+ final IType r = ft.getReturnType();
+ if (containsParameterPack(r))
+ return true;
+ final IType[] ps = ft.getParameterTypes();
+ for (IType p : ps) {
+ if (containsParameterPack(p))
+ return true;
+ }
+
+ } else if (type instanceof ICPPParameterPackType) {
+ // A pack expansion expands all packs.
+ return false;
+ } else if (type instanceof IArrayType) {
+ final IArrayType atype= (IArrayType) type;
+ // mstodo check array size
+ type= atype.getType();
+ } else if (type instanceof ITypeContainer) {
+ type= ((ITypeContainer) type).getType();
+ } else {
+ return false;
+ }
+ }
+ }
+
public static IType mapToAST(IType type, IASTNode node) {
if (type instanceof IFunctionType) {
final ICPPFunctionType ft = (ICPPFunctionType) type;
@@ -379,7 +429,7 @@ public class SemanticUtil {
if (ret == r) {
return type;
}
- return new CPPFunctionType(ret, ft.getParameterTypes(), ft.isConst(), ft.isVolatile());
+ return new CPPFunctionType(ret, ft.getParameterTypes(), ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
}
if (type instanceof ITypeContainer) {
final ITypeContainer tc = (ITypeContainer) type;
@@ -453,30 +503,6 @@ public class SemanticUtil {
return arg;
}
- /**
- * Adjusts the parameter type according to 8.3.5-3:
- * cv-qualifiers are deleted, arrays and function types are converted to pointers.
- */
- public static IType adjustParameterType(final IType pt, boolean forFunctionType) {
- // bug 239975
- IType t= SemanticUtil.getNestedType(pt, TDEF);
- if (t instanceof IArrayType) {
- IArrayType at = (IArrayType) t;
- return new CPPPointerType(at.getType());
- }
- if (t instanceof IFunctionType) {
- return new CPPPointerType(pt);
- }
-
- // 8.3.5-3
- // Any cv-qualifier modifying a parameter type is deleted. The parameter type remains
- // to be qualified.
- if (forFunctionType && SemanticUtil.getCVQualifier(t) != CVQualifier._) {
- return SemanticUtil.getNestedType(t, TDEF | ALLCVQ);
- }
- return pt;
- }
-
public static IType addQualifiers(IType baseType, boolean cnst, boolean vol) {
if (cnst || vol) {
if (baseType instanceof IQualifierType) {
@@ -550,4 +576,14 @@ public class SemanticUtil {
}
return false;
}
+
+ public static boolean isVoidType(IType ptype) {
+ while (ptype instanceof ITypedef) {
+ ptype= ((ITypedef) ptype).getType();
+ }
+ if (ptype instanceof IBasicType) {
+ return ((IBasicType) ptype).getKind() == Kind.eVoid;
+ }
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
index 673529a4ef0..734ccd0dd5f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
@@ -70,6 +70,7 @@ public class ExpressionWriter extends NodeWriter{
private static final String TYPEID_OP = "typeid ("; //$NON-NLS-1$
private static final String OPEN_BRACKET_OP = "("; //$NON-NLS-1$
private static final String SIZEOF_OP = "sizeof "; //$NON-NLS-1$
+ private static final String SIZEOF_PARAMETER_PACK_OP = "sizeof... "; //$NON-NLS-1$
private static final String NOT_OP = "!"; //$NON-NLS-1$
private static final String TILDE_OP = "~"; //$NON-NLS-1$
private static final String AMPERSAND_OP = "&"; //$NON-NLS-1$
@@ -247,6 +248,7 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_tilde:
case IASTUnaryExpression.op_not:
case IASTUnaryExpression.op_sizeof:
+ case IASTUnaryExpression.op_sizeofParameterPack:
case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_throw:
case ICPPASTUnaryExpression.op_typeid:
@@ -296,6 +298,8 @@ public class ExpressionWriter extends NodeWriter{
return NOT_OP;
case IASTUnaryExpression.op_sizeof:
return SIZEOF_OP;
+ case IASTUnaryExpression.op_sizeofParameterPack:
+ return SIZEOF_PARAMETER_PACK_OP;
case IASTUnaryExpression.op_bracketedPrimary:
return OPEN_BRACKET_OP;
case ICPPASTUnaryExpression.op_throw:
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexCPPSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexCPPSignatureUtil.java
index d05cf79b67c..882299462e7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexCPPSignatureUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexCPPSignatureUtil.java
@@ -16,19 +16,19 @@ package org.eclipse.cdt.internal.core.index;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.core.runtime.CoreException;
/**
@@ -59,8 +59,8 @@ public class IndexCPPSignatureUtil {
buffer.append(getTemplateArgString(partial.getTemplateArguments(), false));
}
- if (binding instanceof IFunction) {
- IFunction function = (IFunction) binding;
+ if (binding instanceof ICPPFunction) {
+ IFunction function = (ICPPFunction) binding;
buffer.append(getFunctionParameterString(function.getType()));
}
if (binding instanceof ICPPMethod && !(binding instanceof ICPPConstructor)) {
@@ -86,19 +86,11 @@ public class IndexCPPSignatureUtil {
/**
* Constructs a string in the format:
* (paramName1,paramName2,...)
- *
- * @param fType
- * @return
- * @throws DOMException
*/
- private static String getFunctionParameterString(IFunctionType fType) throws DOMException {
- IType[] types = fType.getParameterTypes();
- if (types.length == 1) {
- if (types[0] instanceof IBasicType) {
- if (((IBasicType) types[0]).getKind() == Kind.eVoid) {
- types = new IType[0];
- }
- }
+ private static String getFunctionParameterString(IFunctionType functionType) throws DOMException {
+ IType[] types = functionType.getParameterTypes();
+ if (types.length == 1 && SemanticUtil.isVoidType(types[0])) {
+ types = new IType[0];
}
StringBuilder result = new StringBuilder();
result.append('(');
@@ -108,6 +100,12 @@ public class IndexCPPSignatureUtil {
}
result.append(ASTTypeUtil.getType(types[i]));
}
+ if (functionType instanceof ICPPFunctionType && ((ICPPFunctionType) functionType).takesVarArgs()) {
+ if (types.length != 0) {
+ result.append(',');
+ }
+ result.append("..."); //$NON-NLS-1$
+ }
result.append(')');
return result.toString();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
index 55a42dee834..2fb5cfaa313 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
@@ -38,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
@@ -56,6 +57,7 @@ import org.eclipse.cdt.core.index.IIndexMacroContainer;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
@@ -132,7 +134,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
IType[] p= ft.getParameterTypes();
IType[] p2= getCompositeTypes(p);
if (r != r2 || p != p2) {
- return new CPPFunctionType(r2, p2, ft.isConst(), ft.isVolatile());
+ return new CPPFunctionType(r2, p2, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
}
return ft;
}
@@ -165,6 +167,15 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
}
return rt;
}
+ if (rtype instanceof ICPPParameterPackType) {
+ ICPPParameterPackType rt= (ICPPParameterPackType) rtype;
+ IType r= rt.getType();
+ IType r2= getCompositeType(r);
+ if (r != r2) {
+ return new CPPParameterPackType(r2);
+ }
+ return rt;
+ }
if (rtype instanceof IQualifierType) {
IQualifierType qt= (IQualifierType) rtype;
IType r= qt.getType();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java
index 6ca5124904f..3f3e7650e5a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java
@@ -75,6 +75,14 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
public boolean takesVarArgs() throws DOMException {
return ((ICPPFunction)rbinding).takesVarArgs();
}
+
+ public int getRequiredArgumentCount() throws DOMException {
+ return ((ICPPFunction)rbinding).getRequiredArgumentCount();
+ }
+
+ public boolean hasParameterPack() {
+ return ((ICPPFunction)rbinding).hasParameterPack();
+ }
@Override
public Object clone() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameter.java
index bfc07fff866..ca0b07961c8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameter.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Symbian Software Systems and others.
+ * Copyright (c) 2007, 2009 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Andrew Ferguson (Symbian) - Initial implementation
+ * Andrew Ferguson (Symbian) - Initial implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
@@ -22,4 +23,8 @@ class CompositeCPPParameter extends CompositeCPPVariable implements ICPPParamete
public boolean hasDefaultValue() {
return ((ICPPParameter)rbinding).hasDefaultValue();
}
+
+ public boolean isParameterPack() {
+ return ((ICPPParameter)rbinding).isParameterPack();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateNonTypeParameter.java
index cee34ca5de4..240339854c9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateNonTypeParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateNonTypeParameter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Symbian Software Systems and others.
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -44,6 +44,10 @@ public class CompositeCPPTemplateNonTypeParameter extends CompositeCPPVariable i
public int getParameterID() {
return ((ICPPTemplateParameter)rbinding).getParameterID();
}
+
+ public boolean isParameterPack() {
+ return ((ICPPTemplateParameter)rbinding).isParameterPack();
+ }
public ICPPTemplateArgument getDefaultValue() {
try {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java
index 9462194cf41..be941ebb728 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTemplateParameter.java
@@ -60,6 +60,10 @@ public class CompositeCPPTemplateTemplateParameter extends CompositeCPPBinding
return ((ICPPTemplateParameter)rbinding).getParameterID();
}
+ public boolean isParameterPack() {
+ return ((ICPPTemplateParameter)rbinding).isParameterPack();
+ }
+
public boolean isSameType(IType type) {
return ((IType)rbinding).isSameType(type);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTypeParameter.java
index 969cfdee656..29d7d9b6fad 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTypeParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTemplateTypeParameter.java
@@ -50,6 +50,10 @@ public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding
return ((ICPPTemplateParameter)rbinding).getParameterID();
}
+ public boolean isParameterPack() {
+ return ((ICPPTemplateParameter)rbinding).isParameterPack();
+ }
+
public boolean isSameType(IType type) {
return ((IType)rbinding).isSameType(type);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
index 71fcc8279b8..b6684040c5b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
@@ -187,10 +187,11 @@ public class PDOM extends PlatformObject implements IPDOM {
* 92.0 - simplification of basic types, bug 231859.
* 93.0 - further simplification of basic types, bug 231859.
* 94.0 - new model for storing types, bug 294306.
+ * 95.0 - parameter packs, bug 294730.
*/
- private static final int MIN_SUPPORTED_VERSION= version(94, 0);
- private static final int MAX_SUPPORTED_VERSION= version(94, Short.MAX_VALUE);
- private static final int DEFAULT_VERSION = version(94, 0);
+ private static final int MIN_SUPPORTED_VERSION= version(95, 0);
+ private static final int MAX_SUPPORTED_VERSION= version(95, Short.MAX_VALUE);
+ private static final int DEFAULT_VERSION = version(95, 0);
private static int version(int major, int minor) {
return (major << 16) + minor;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotation.java
index 64668dc6e71..4fedb18e151 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotation.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotation.java
@@ -108,7 +108,7 @@ class PDOMCPPAnnotation {
* @param annotation Annotation containing visibility information.
* @return The visibility component of the annotation.
*/
- public static int getVisibility(byte annotation) {
+ public static int getVisibility(int annotation) {
return (annotation >> VISIBILITY_OFFSET) & VISIBILITY_MASK;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java
index 5f44feb0d89..34efdd4a2bf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java
@@ -38,6 +38,8 @@ import org.eclipse.core.runtime.CoreException;
*/
class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverloader {
+ private static final short ANNOT_PARAMETER_PACK = 0x100;
+
/**
* Offset of total number of function parameters (relative to the
* beginning of the record).
@@ -70,15 +72,18 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
* Offset of annotation information (relative to the beginning of the
* record).
*/
- private static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // byte
+ private static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short
+
+ private static final int REQUIRED_ARG_COUNT = ANNOTATION + 2;
/**
* The size in bytes of a PDOMCPPFunction record in the database.
*/
@SuppressWarnings("hiding")
- protected static final int RECORD_SIZE = ANNOTATION + 1;
+ protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT + 4;
- private byte annotation= -1;
+ private short fAnnotation= -1;
+ private int fRequiredArgCount= -1;
private ICPPFunctionType fType;
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function, boolean setTypes) throws CoreException, DOMException {
@@ -86,13 +91,21 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
Database db = getDB();
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
- db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(function));
-
+ db.putShort(record + ANNOTATION, getAnnotation(function));
+ db.putInt(record + REQUIRED_ARG_COUNT, function.getRequiredArgumentCount());
if (setTypes) {
initData(function.getType(), function.getParameters(), extractExceptionSpec(function));
}
}
+ private short getAnnotation(ICPPFunction function) throws DOMException {
+ int annot= PDOMCPPAnnotation.encodeAnnotation(function);
+ if (function.hasParameterPack()) {
+ annot |= ANNOT_PARAMETER_PACK;
+ }
+ return (short) annot;
+ }
+
public void initData(ICPPFunctionType ftype, ICPPParameter[] params, IType[] exceptionSpec) {
try {
setType(ftype);
@@ -109,11 +122,13 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
ICPPFunction func= (ICPPFunction) newBinding;
ICPPFunctionType newType;
ICPPParameter[] newParams;
- byte newAnnotation;
+ short newAnnotation;
+ int newBindingRequiredArgCount;
try {
newType= func.getType();
newParams = func.getParameters();
- newAnnotation = PDOMCPPAnnotation.encodeAnnotation(func);
+ newAnnotation = getAnnotation(func);
+ newBindingRequiredArgCount= func.getRequiredArgumentCount();
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
@@ -122,23 +137,35 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
linkage.storeType(record+FUNCTION_TYPE, newType);
PDOMCPPParameter oldParams= getFirstParameter(null);
+ int requiredCount;
if (oldParams != null && hasDeclaration()) {
+ int parCount= 0;
+ requiredCount= 0;
for (ICPPParameter newPar : newParams) {
+ parCount++;
+ if (parCount <= newBindingRequiredArgCount && !oldParams.hasDefaultValue())
+ requiredCount= parCount;
oldParams.update(newPar);
long next= oldParams.getNextPtr();
if (next == 0)
break;
oldParams= new PDOMCPPParameter(linkage, next, null);
}
+ if (parCount < newBindingRequiredArgCount) {
+ requiredCount= newBindingRequiredArgCount;
+ }
} else {
+ requiredCount= newBindingRequiredArgCount;
setParameters(newParams);
if (oldParams != null) {
oldParams.delete(linkage);
}
}
final Database db = getDB();
- db.putByte(record + ANNOTATION, newAnnotation);
- annotation= newAnnotation;
+ db.putShort(record + ANNOTATION, newAnnotation);
+ fAnnotation= newAnnotation;
+ db.putInt(record + REQUIRED_ARG_COUNT, requiredCount);
+ fRequiredArgCount= requiredCount;
long oldRec = db.getRecPtr(record+EXCEPTION_SPEC);
storeExceptionSpec(extractExceptionSpec(func));
@@ -213,14 +240,31 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
return rec != 0 ? new PDOMCPPParameter(getLinkage(), rec, type) : null;
}
- public boolean isInline() throws DOMException {
+ public boolean isInline() {
return getBit(getAnnotation(), PDOMCAnnotation.INLINE_OFFSET);
}
- final protected byte getAnnotation() {
- if (annotation == -1)
- annotation= getByte(record + ANNOTATION);
- return annotation;
+
+ public int getRequiredArgumentCount() throws DOMException {
+ if (fRequiredArgCount == -1) {
+ try {
+ fRequiredArgCount= getDB().getInt(record + REQUIRED_ARG_COUNT);
+ } catch (CoreException e) {
+ fRequiredArgCount= 0;
+ }
+ }
+ return fRequiredArgCount;
+ }
+
+ final protected short getAnnotation() {
+ if (fAnnotation == -1) {
+ try {
+ fAnnotation= getDB().getShort(record + ANNOTATION);
+ } catch (CoreException e) {
+ fAnnotation= 0;
+ }
+ }
+ return fAnnotation;
}
public boolean isExternC() throws DOMException {
@@ -270,21 +314,21 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
return fType;
}
- public boolean isAuto() throws DOMException {
+ public boolean isAuto() {
// ISO/IEC 14882:2003 7.1.1.2
return false;
}
- public boolean isExtern() throws DOMException {
+ public boolean isExtern() {
return getBit(getAnnotation(), PDOMCAnnotation.EXTERN_OFFSET);
}
- public boolean isRegister() throws DOMException {
+ public boolean isRegister() {
// ISO/IEC 14882:2003 7.1.1.2
return false;
}
- public boolean isStatic() throws DOMException {
+ public boolean isStatic() {
return getBit(getAnnotation(), PDOMCAnnotation.STATIC_OFFSET);
}
@@ -292,6 +336,10 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
return getBit(getAnnotation(), PDOMCAnnotation.VARARGS_OFFSET);
}
+ public boolean hasParameterPack() {
+ return getBit(getAnnotation(), ANNOT_PARAMETER_PACK);
+ }
+
@Override
public Object clone() {
throw new PDOMNotImplementedError();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
index b4e58cb1503..28df5475f3f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
@@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
-import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
@@ -63,41 +62,62 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
* Offset of annotation information (relative to the beginning of the
* record).
*/
- protected static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // byte
+ protected static final int ANNOTATION_OFFSET = EXCEPTION_SPEC + Database.PTR_SIZE; // short
+ private static final int REQUIRED_ARG_COUNT_OFFSET= ANNOTATION_OFFSET + 2;
/**
* The size in bytes of a PDOMCPPFunction record in the database.
*/
@SuppressWarnings("hiding")
- protected static final int RECORD_SIZE = ANNOTATION + 1;
+ protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT_OFFSET + 4;
+
+
+ private static final short ANNOT_HAS_PACK = 0x100;
private ICPPFunctionType fType;
+ private short fAnnotation= -1;
+
+ private int fRequiredArgCount= -1;
public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPFunction astFunction, PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPSpecialization) astFunction, specialized);
Database db = getDB();
try {
- IParameter[] astParams= astFunction.getParameters();
+ ICPPParameter[] astParams= astFunction.getParameters();
IFunctionType astFt= astFunction.getType();
if (astFt != null) {
getLinkage().storeType(record + FUNCTION_TYPE, astFt);
}
- ICPPFunction spAstFunc= (ICPPFunction) ((ICPPSpecialization)astFunction).getSpecializedBinding();
- ICPPParameter[] spAstParams= spAstFunc.getParameters();
-
- final int length= Math.min(spAstParams.length, astParams.length);
- db.putInt(record + NUM_PARAMS, length);
-
- db.putRecPtr(record + FIRST_PARAM, 0);
- PDOMCPPParameterSpecialization next= null;
- for (int i= length-1; i >= 0; --i) {
- PDOMCPPParameter par= new PDOMCPPParameter(linkage, specialized, spAstParams[i], null);
- next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], par, next);
+ ICPPFunction origAstFunc= (ICPPFunction) ((ICPPSpecialization)astFunction).getSpecializedBinding();
+ ICPPParameter[] origAstParams= origAstFunc.getParameters();
+ if (origAstParams.length == 0) {
+ db.putInt(record + NUM_PARAMS, 0);
+ db.putRecPtr(record + FIRST_PARAM, 0);
+ } else {
+ final int length= astParams.length;
+ db.putInt(record + NUM_PARAMS, length);
+
+ db.putRecPtr(record + FIRST_PARAM, 0);
+ PDOMCPPParameter origPar= null;
+ PDOMCPPParameterSpecialization next= null;
+ for (int i= length-1; i >= 0; --i) {
+ // There may be fewer or less original parameters, because of parameter packs.
+ if (i < origAstParams.length-1) {
+ // Normal case
+ origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null);
+ } else if (origPar == null) {
+ // Use last parameter
+ origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[origAstParams.length-1], null);
+ }
+ next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], origPar, next);
+ }
+ db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
}
- db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
- db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(astFunction));
+ fAnnotation = getAnnotation(astFunction);
+ db.putShort(record + ANNOTATION_OFFSET, fAnnotation);
+ db.putInt(record + REQUIRED_ARG_COUNT_OFFSET, astFunction.getRequiredArgumentCount());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
@@ -115,6 +135,14 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
+ private short getAnnotation(ICPPFunction astFunction) throws DOMException {
+ int annot= PDOMCPPAnnotation.encodeAnnotation(astFunction);
+ if (astFunction.hasParameterPack()) {
+ annot |= ANNOT_HAS_PACK;
+ }
+ return (short) annot;
+ }
+
public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@@ -130,11 +158,22 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
public boolean isInline() throws DOMException {
- return getBit(getByte(record + ANNOTATION), PDOMCAnnotation.INLINE_OFFSET);
+ return getBit(readAnnotation(), PDOMCAnnotation.INLINE_OFFSET);
+ }
+
+ private short readAnnotation() {
+ if (fAnnotation == -1) {
+ try {
+ fAnnotation= getDB().getShort(record + ANNOTATION_OFFSET);
+ } catch (CoreException e) {
+ fAnnotation= 0;
+ }
+ }
+ return fAnnotation;
}
public boolean isMutable() throws DOMException {
- throw new PDOMNotImplementedError();
+ return false;
}
public IScope getFunctionScope() throws DOMException {
@@ -182,11 +221,11 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
public boolean isExtern() throws DOMException {
- return getBit(getByte(record + ANNOTATION), PDOMCAnnotation.EXTERN_OFFSET);
+ return getBit(readAnnotation(), PDOMCAnnotation.EXTERN_OFFSET);
}
public boolean isExternC() throws DOMException {
- return getBit(getByte(record + ANNOTATION), PDOMCPPAnnotation.EXTERN_C_OFFSET);
+ return getBit(readAnnotation(), PDOMCPPAnnotation.EXTERN_C_OFFSET);
}
public boolean isRegister() throws DOMException {
@@ -195,11 +234,27 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
public boolean isStatic() throws DOMException {
- return getBit(getByte(record + ANNOTATION), PDOMCAnnotation.STATIC_OFFSET);
+ return getBit(readAnnotation(), PDOMCAnnotation.STATIC_OFFSET);
}
public boolean takesVarArgs() throws DOMException {
- return getBit(getByte(record + ANNOTATION), PDOMCAnnotation.VARARGS_OFFSET);
+ return getBit(readAnnotation(), PDOMCAnnotation.VARARGS_OFFSET);
+ }
+
+
+ public int getRequiredArgumentCount() throws DOMException {
+ if (fRequiredArgCount == -1) {
+ try {
+ fRequiredArgCount= getDB().getInt(record + REQUIRED_ARG_COUNT_OFFSET);
+ } catch (CoreException e) {
+ fRequiredArgCount= 0;
+ }
+ }
+ return fRequiredArgCount;
+ }
+
+ public boolean hasParameterPack() {
+ return getBit(readAnnotation(), ANNOT_HAS_PACK);
}
public boolean isConst() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
index 60602d5cd98..43a932f73e1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
@@ -70,6 +70,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
@@ -987,6 +988,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return CPPPointerType.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.REFERENCE:
return CPPReferenceType.unmarshal(firstByte, buffer);
+ case ITypeMarshalBuffer.PACK_EXPANSION:
+ return CPPParameterPackType.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.POINTER_TO_MEMBER:
return CPPPointerToMemberType.unmarshal(firstByte, buffer);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java
index 040003f33f8..8817e580a76 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX - Initial API and implementation
+ * Doug Schaefer (QNX) - Initial API and implementation
* IBM Corporation
* Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems)
@@ -37,8 +37,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
import org.eclipse.core.runtime.CoreException;
/**
- * @author Doug Schaefer
- *
+ * Method
*/
class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
@@ -137,7 +136,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
@Override
- public boolean isExtern() throws DOMException {
+ public boolean isExtern() {
// ISO/IEC 14882:2003 9.2.6
return false;
}
@@ -148,13 +147,13 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
@Override
- public boolean isAuto() throws DOMException {
+ public boolean isAuto() {
// ISO/IEC 14882:2003 9.2.6
return false;
}
@Override
- public boolean isRegister() throws DOMException {
+ public boolean isRegister() {
// ISO/IEC 14882:2003 9.2.6
return false;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java
index cb681e6b373..f7ae8fc32c2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX - Initial API and implementation
+ * Bryan Wilkinson (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -27,8 +27,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
import org.eclipse.core.runtime.CoreException;
/**
- * @author Bryan Wilkinson
- *
+ * Specialization of a method
*/
class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
implements ICPPMethod {
@@ -111,7 +110,7 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
}
public int getVisibility() throws DOMException {
- return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION));
+ return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION_OFFSET));
}
@Override
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java
index 21a270fbdb3..a867040f200 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX - Initial API and implementation
+ * Bryan Wilkinson (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -25,8 +25,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
import org.eclipse.core.runtime.CoreException;
/**
- * @author Bryan Wilkinson
- *
+ * Template for a method.
*/
class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMethod {
@@ -115,7 +114,7 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
}
@Override
- public boolean isExtern() throws DOMException {
+ public boolean isExtern() {
// ISO/IEC 14882:2003 9.2.6
return false;
}
@@ -126,18 +125,18 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
}
@Override
- public boolean isAuto() throws DOMException {
+ public boolean isAuto() {
// ISO/IEC 14882:2003 9.2.6
return false;
}
@Override
- public boolean isRegister() throws DOMException {
+ public boolean isRegister() {
// ISO/IEC 14882:2003 9.2.6
return false;
}
- public boolean isPureVirtual() throws DOMException {
+ public boolean isPureVirtual() {
return false;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java
index ca71c7fa9d5..4f37726fd58 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java
@@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
@@ -79,7 +80,9 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
// Bug 297438: Don't clear the property of having a default value.
if (newPar.hasDefaultValue()) {
db.putByte(record + FLAGS, FLAG_DEFAULT_VALUE);
- }
+ } else if (newPar.isParameterPack()) {
+ db.putByte(record + FLAGS, (byte) 0);
+ }
storeAnnotations(db, newPar);
final char[] newName = newPar.getNameCharArray();
@@ -172,6 +175,10 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
return hasFlag(FLAG_DEFAULT_VALUE, false, FLAGS);
}
+ public boolean isParameterPack() {
+ return getType() instanceof ICPPParameterPackType;
+ }
+
private boolean hasFlag(byte flag, boolean defValue, int offset) {
try {
byte myflags= getDB().getByte(record + offset);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java
index 022c54f6bbd..f2a8209a161 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameterSpecialization.java
@@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@@ -41,9 +42,9 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
fType= t;
}
- public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, IParameter param,
- PDOMCPPParameter specialized, PDOMCPPParameterSpecialization next) throws CoreException {
- super(linkage, parent, (ICPPSpecialization) param, specialized);
+ public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam,
+ PDOMCPPParameter original, PDOMCPPParameterSpecialization next) throws CoreException {
+ super(linkage, parent, (ICPPSpecialization) astParam, original);
fType= null; // this constructor is used for adding parameters to the database, only.
Database db = getDB();
@@ -60,11 +61,6 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
return IIndexCPPBindingConstants.CPP_PARAMETER_SPECIALIZATION;
}
- public PDOMCPPParameterSpecialization getNextParameter(IType t) throws CoreException {
- long rec = getNextPtr();
- return rec != 0 ? new PDOMCPPParameterSpecialization(getLinkage(), rec, t) : null;
- }
-
long getNextPtr() throws CoreException {
long rec = getDB().getRecPtr(record + NEXT_PARAM);
return rec;
@@ -116,6 +112,10 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
return getParameter().hasDefaultValue();
}
+ public boolean isParameterPack() {
+ return getType() instanceof ICPPParameterPackType;
+ }
+
public boolean isAuto() throws DOMException {
return getParameter().isAuto();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateNonTypeParameter.java
index ec5cbcad85f..3a4cd276b70 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateNonTypeParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateNonTypeParameter.java
@@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
@@ -45,8 +46,8 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
protected static final int RECORD_SIZE = DEFAULTVAL + Database.PTR_SIZE;
private int fCachedParamID= -1;
+ private IType fType;
-
public PDOMCPPTemplateNonTypeParameter(PDOMLinkage linkage, PDOMNode parent,
ICPPTemplateNonTypeParameter param) throws CoreException {
super(linkage, parent, param.getNameCharArray());
@@ -110,15 +111,18 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
}
public short getParameterPosition() {
- readParamID();
- return (short) fCachedParamID;
+ return (short) getParameterID();
}
public short getTemplateNestingLevel() {
readParamID();
- return (short)(fCachedParamID >> 16);
+ return (short)(getParameterID() >> 16);
}
+ public boolean isParameterPack() {
+ return getType() instanceof ICPPParameterPackType;
+ }
+
public int getParameterID() {
readParamID();
return fCachedParamID;
@@ -131,7 +135,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
fCachedParamID= db.getInt(record + PARAMETERID);
} catch (CoreException e) {
CCorePlugin.log(e);
- fCachedParamID= -2;
+ fCachedParamID= Integer.MAX_VALUE;
}
}
}
@@ -169,12 +173,14 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
}
public IType getType() {
- try {
- return getLinkage().loadType(record + TYPE_OFFSET);
- } catch (CoreException e) {
- CCorePlugin.log(e);
- return null;
+ if (fType == null) {
+ try {
+ fType= getLinkage().loadType(record + TYPE_OFFSET);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
}
+ return fType;
}
public IValue getInitialValue() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java
index 8d3ef1429d9..c69eb6d4c71 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTemplateParameter.java
@@ -51,6 +51,8 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
implements ICPPTemplateTemplateParameter, ICPPUnknownBinding, ICPPUnknownType, IIndexType,
IPDOMCPPTemplateParameter, IPDOMCPPTemplateParameterOwner {
+ private static final int PACK_BIT = 1 << 31;
+
private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE;
private static final int MEMBERLIST = DEFAULT_TYPE + Database.TYPE_SIZE;
private static final int PARAMETERID= MEMBERLIST + Database.PTR_SIZE;
@@ -67,7 +69,11 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
super(linkage, parent, param.getNameCharArray());
final Database db = getDB();
- db.putInt(record + PARAMETERID, param.getParameterID());
+ int id= param.getParameterID();
+ if (param.isParameterPack()) {
+ id |= PACK_BIT;
+ }
+ db.putInt(record + PARAMETERID, id);
final ICPPTemplateParameter[] origParams= param.getTemplateParameters();
final IPDOMCPPTemplateParameter[] params = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
long rec= PDOMTemplateParameterArray.putArray(db, params);
@@ -89,18 +95,22 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
}
public short getParameterPosition() {
- readParamID();
- return (short) fCachedParamID;
+ return (short) getParameterID();
}
public short getTemplateNestingLevel() {
readParamID();
- return (short)(fCachedParamID >> 16);
+ return (short)(getParameterID() >> 16);
}
+ public boolean isParameterPack() {
+ readParamID();
+ return (fCachedParamID & PACK_BIT) != 0;
+ }
+
public int getParameterID() {
readParamID();
- return fCachedParamID;
+ return fCachedParamID & ~PACK_BIT;
}
private void readParamID() {
@@ -110,7 +120,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
fCachedParamID= db.getInt(record + PARAMETERID);
} catch (CoreException e) {
CCorePlugin.log(e);
- fCachedParamID= -2;
+ fCachedParamID= Integer.MAX_VALUE;
}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTypeParameter.java
index 9059f8b1aec..b19fa32be32 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTypeParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateTypeParameter.java
@@ -43,6 +43,8 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
ICPPTemplateTypeParameter, ICPPUnknownBinding, ICPPUnknownType, IIndexType,
IPDOMCPPTemplateParameter {
+ private static final int PACK_BIT = 1 << 31;
+
private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE;
private static final int MEMBERLIST = DEFAULT_TYPE + Database.TYPE_SIZE;
private static final int PARAMETERID= MEMBERLIST + Database.PTR_SIZE;
@@ -57,7 +59,11 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
super(linkage, parent, param.getNameCharArray());
final Database db = getDB();
- db.putInt(record + PARAMETERID, param.getParameterID());
+ int id= param.getParameterID();
+ if (param.isParameterPack()) {
+ id |= PACK_BIT;
+ }
+ db.putInt(record + PARAMETERID, id);
}
public PDOMCPPTemplateTypeParameter(PDOMLinkage linkage, long bindingRecord) {
@@ -75,18 +81,22 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
}
public short getParameterPosition() {
- readParamID();
- return (short) fCachedParamID;
+ return (short) getParameterID();
}
public short getTemplateNestingLevel() {
readParamID();
- return (short)(fCachedParamID >> 16);
+ return (short)(getParameterID() >> 16);
}
+ public boolean isParameterPack() {
+ readParamID();
+ return (fCachedParamID & PACK_BIT) != 0;
+ }
+
public int getParameterID() {
readParamID();
- return fCachedParamID;
+ return fCachedParamID & ~PACK_BIT;
}
private void readParamID() {
@@ -96,7 +106,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
fCachedParamID= db.getInt(record + PARAMETERID);
} catch (CoreException e) {
CCorePlugin.log(e);
- fCachedParamID= -2;
+ fCachedParamID= Integer.MAX_VALUE;
}
}
}

Back to the top