mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Split CPPVisitor.createType(IASTDeclarator declarator) into smaller
methods.
This commit is contained in:
parent
c3d94d1bf2
commit
1a8212ca62
1 changed files with 60 additions and 57 deletions
|
@ -1843,11 +1843,39 @@ public class CPPVisitor extends ASTQueries {
|
||||||
|
|
||||||
if (declSpec instanceof ICPPASTSimpleDeclSpecifier &&
|
if (declSpec instanceof ICPPASTSimpleDeclSpecifier &&
|
||||||
((ICPPASTSimpleDeclSpecifier) declSpec).getType() == IASTSimpleDeclSpecifier.t_auto) {
|
((ICPPASTSimpleDeclSpecifier) declSpec).getType() == IASTSimpleDeclSpecifier.t_auto) {
|
||||||
|
return createAutoType(declSpec, declarator);
|
||||||
|
}
|
||||||
|
|
||||||
|
IType type = createType(declSpec);
|
||||||
|
type = createType(type, declarator);
|
||||||
|
|
||||||
|
// C++ specification 8.3.4.3 and 8.5.1.4
|
||||||
|
IASTNode initClause= declarator.getInitializer();
|
||||||
|
if (initClause instanceof IASTEqualsInitializer) {
|
||||||
|
initClause= ((IASTEqualsInitializer) initClause).getInitializerClause();
|
||||||
|
}
|
||||||
|
if (initClause instanceof IASTInitializerList) {
|
||||||
|
IType t= SemanticUtil.getNestedType(type, TDEF);
|
||||||
|
if (t instanceof IArrayType) {
|
||||||
|
IArrayType at= (IArrayType) t;
|
||||||
|
if (at.getSize() == null) {
|
||||||
|
type= new CPPArrayType(at.getType(), Value.create(((IASTInitializerList) initClause).getSize()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPackExpansion) {
|
||||||
|
type= new CPPParameterPackType(type);
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IType createAutoType(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
||||||
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
||||||
return createAutoFunctionType(declSpec, (ICPPASTFunctionDeclarator) declarator);
|
return createAutoFunctionType(declSpec, (ICPPASTFunctionDeclarator) declarator);
|
||||||
}
|
}
|
||||||
IASTInitializerClause autoInitClause= null;
|
IASTInitializerClause autoInitClause= null;
|
||||||
parent = parent.getParent();
|
IASTNode parent = declarator.getParent().getParent();
|
||||||
if (parent instanceof ICPPASTNewExpression) {
|
if (parent instanceof ICPPASTNewExpression) {
|
||||||
IASTInitializer initializer = ((ICPPASTNewExpression) parent).getInitializer();
|
IASTInitializer initializer = ((ICPPASTNewExpression) parent).getInitializer();
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
|
@ -1881,7 +1909,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
name.setOffset(((ASTNode) forInit).getOffset());
|
name.setOffset(((ASTNode) forInit).getOffset());
|
||||||
beginExpr= new CPPASTFunctionCallExpression(
|
beginExpr= new CPPASTFunctionCallExpression(
|
||||||
new CPPASTIdExpression(name),
|
new CPPASTIdExpression(name),
|
||||||
new IASTInitializerClause[] {forInit.copy()});
|
new IASTInitializerClause[] { forInit.copy() });
|
||||||
}
|
}
|
||||||
autoInitClause= new CPPASTUnaryExpression(IASTUnaryExpression.op_star, beginExpr);
|
autoInitClause= new CPPASTUnaryExpression(IASTUnaryExpression.op_star, beginExpr);
|
||||||
autoInitClause.setParent(forStmt);
|
autoInitClause.setParent(forStmt);
|
||||||
|
@ -1901,31 +1929,6 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return createAutoType(autoInitClause, declSpec, declarator);
|
return createAutoType(autoInitClause, declSpec, declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IType type = createType(declSpec);
|
|
||||||
type = createType(type, declarator);
|
|
||||||
|
|
||||||
// C++ specification 8.3.4.3 and 8.5.1.4
|
|
||||||
IASTNode initClause= declarator.getInitializer();
|
|
||||||
if (initClause instanceof IASTEqualsInitializer) {
|
|
||||||
initClause= ((IASTEqualsInitializer) initClause).getInitializerClause();
|
|
||||||
}
|
|
||||||
if (initClause instanceof IASTInitializerList) {
|
|
||||||
IType t= SemanticUtil.getNestedType(type, TDEF);
|
|
||||||
if (t instanceof IArrayType) {
|
|
||||||
IArrayType at= (IArrayType) t;
|
|
||||||
if (at.getSize() == null) {
|
|
||||||
type= new CPPArrayType(at.getType(), Value.create(((IASTInitializerList) initClause).getSize()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPackExpansion) {
|
|
||||||
type= new CPPParameterPackType(type);
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IType createAutoType(IASTInitializerClause initClause, IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
private static IType createAutoType(IASTInitializerClause initClause, IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
||||||
// C++0x: 7.1.6.4
|
// C++0x: 7.1.6.4
|
||||||
if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) {
|
if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue