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 &&
|
||||
((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) {
|
||||
return createAutoFunctionType(declSpec, (ICPPASTFunctionDeclarator) declarator);
|
||||
}
|
||||
IASTInitializerClause autoInitClause= null;
|
||||
parent = parent.getParent();
|
||||
IASTNode parent = declarator.getParent().getParent();
|
||||
if (parent instanceof ICPPASTNewExpression) {
|
||||
IASTInitializer initializer = ((ICPPASTNewExpression) parent).getInitializer();
|
||||
if (initializer != null) {
|
||||
|
@ -1901,31 +1929,6 @@ public class CPPVisitor extends ASTQueries {
|
|||
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) {
|
||||
// C++0x: 7.1.6.4
|
||||
if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue