diff options
author | Markus Schorn | 2009-01-22 11:40:24 +0000 |
---|---|---|
committer | Markus Schorn | 2009-01-22 11:40:24 +0000 |
commit | 6bf82f61ba0e2508f9994b3b5a1f0dd554ad7777 (patch) | |
tree | c3f476aad7bdc03e0b915d92acde227179dac5ad /core | |
parent | b023838ace9a7239997f0ac15b7d8b3a652e55ff (diff) | |
download | org.eclipse.cdt-6bf82f61ba0e2508f9994b3b5a1f0dd554ad7777.tar.gz org.eclipse.cdt-6bf82f61ba0e2508f9994b3b5a1f0dd554ad7777.tar.xz org.eclipse.cdt-6bf82f61ba0e2508f9994b3b5a1f0dd554ad7777.zip |
Fixes a performance issue introduced by fix for 261417.
Diffstat (limited to 'core')
6 files changed, 33 insertions, 23 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index bc9748f036f..d95b125a8a9 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -1759,7 +1759,7 @@ public class AST2CPPTests extends AST2BaseTest { IASTExpressionStatement expStatement = (IASTExpressionStatement) ((IASTCompoundStatement) def .getBody()).getStatements()[0]; assertTrue(expStatement.getExpression() instanceof IASTLiteralExpression); - IType type = CPPVisitor.getExpressionType(expStatement.getExpression()); + IType type = expStatement.getExpression().getExpressionType(); assertTrue(type instanceof IPointerType); assertSame(((IPointerType) type).getType(), A); @@ -1768,7 +1768,7 @@ public class AST2CPPTests extends AST2BaseTest { expStatement = (IASTExpressionStatement) ((IASTCompoundStatement) def .getBody()).getStatements()[0]; IASTUnaryExpression ue = (IASTUnaryExpression) expStatement.getExpression(); - type = CPPVisitor.getExpressionType(ue); + type = ue.getExpressionType(); assertTrue(type instanceof IQualifierType); assertSame(((IQualifierType) type).getType(), A); @@ -5561,7 +5561,7 @@ public class AST2CPPTests extends AST2BaseTest { IASTDeclarator decltor= ((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclarators()[0]; IASTInitializerExpression init= (IASTInitializerExpression) decltor.getInitializer(); ICPPASTLiteralExpression exp= (ICPPASTLiteralExpression) init.getExpression(); - ICPPBasicType type= (ICPPBasicType) CPPVisitor.getExpressionType(exp); + ICPPBasicType type= (ICPPBasicType) exp.getExpressionType(); assertTrue(type.isLong()); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 6a84587267a..03b3ff2db98 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -1602,7 +1602,7 @@ public class AST2TemplateTests extends AST2BaseTest { IASTName f = col.getName(6); IASTFunctionDefinition fdef = (IASTFunctionDefinition) f.getParent().getParent(); IASTExpressionStatement statement = (IASTExpressionStatement) ((IASTCompoundStatement)fdef.getBody()).getStatements()[0]; - IType type = CPPVisitor.getExpressionType(statement.getExpression()); + IType type = statement.getExpression().getExpressionType(); assertTrue(type.isSameType(p.getType())); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java index ab036d69e44..f15c0c9574d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java @@ -27,6 +27,7 @@ public class CPPASTBinaryExpression extends CPPASTNode implements private int op; private IASTExpression operand1; private IASTExpression operand2; + private IType type; public CPPASTBinaryExpression() { } @@ -108,7 +109,9 @@ public class CPPASTBinaryExpression extends CPPASTNode implements } public IType getExpressionType() { - return CPPVisitor.getExpressionType(this); + if (type == null) { + type= CPPVisitor.getExpressionType(this); + } + return type; } - } 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 c013b188084..b0d54f5aa03 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 @@ -656,6 +656,8 @@ public class CPPSemantics { } } + // this is a workaround, properly fixed on the main branch (bug 237026) + HashSet<IScope> handledScopes= new HashSet<IScope>(); while (scope != null) { if (scope instanceof IIndexScope && data.tu != null) { scope= (ICPPScope) data.tu.mapToASTScope(((IIndexScope) scope)); @@ -741,6 +743,7 @@ public class CPPSemantics { if (blockItem != null) node = blockItem; + handledScopes.add(scope); ICPPScope parentScope = (ICPPScope) getParentScope(scope, data.tu); if (parentScope instanceof ICPPTemplateScope) { IASTNode declNode = node; @@ -756,6 +759,10 @@ public class CPPSemantics { } } } + // workaround on the maintenance branch, proper fix in 6.0, see bug 237026. + while (handledScopes.contains(parentScope)) { + parentScope= (ICPPScope) parentScope.getParent(); + } scope = parentScope; } } @@ -1919,7 +1926,7 @@ public class CPPSemantics { IASTExpression[] exps = (IASTExpression[]) params; IType[] result = new IType[exps.length]; for (int i = 0; i < exps.length; i++) { - result[i] = CPPVisitor.getExpressionType(exps[i]); + result[i] = exps[i].getExpressionType(); } return result; } else if (params instanceof IASTParameterDeclaration[]) { @@ -2240,7 +2247,7 @@ public class CPPSemantics { // target is the left side of an assignment IASTBinaryExpression binaryExp = (IASTBinaryExpression) node.getParent(); IASTExpression exp = binaryExp.getOperand1(); - return CPPVisitor.getExpressionType(exp); + return exp.getExpressionType(); } else if (prop == IASTFunctionCallExpression.PARAMETERS || (prop == IASTExpressionList.NESTED_EXPRESSION && node.getParent().getPropertyInParent() == IASTFunctionCallExpression.PARAMETERS)) { @@ -2372,7 +2379,7 @@ public class CPPSemantics { } } } else { - IType type = CPPVisitor.getExpressionType(exp); + IType type = exp.getExpressionType(); type = getUltimateType(type, false); if (type instanceof IFunctionType) { result = new IFunctionType[] { (IFunctionType) type }; 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 8d378334d1c..b2940d6cbbc 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 @@ -1657,7 +1657,7 @@ public class CPPVisitor extends ASTQueries { if (node == null) return null; if (node instanceof IASTExpression) - return getExpressionType((IASTExpression) node); + return ((IASTExpression) node).getExpressionType(); if (node instanceof IASTTypeId) return createType(((IASTTypeId) node).getAbstractDeclarator()); if (node instanceof IASTParameterDeclaration) @@ -1919,7 +1919,7 @@ public class CPPVisitor extends ASTQueries { final IASTBinaryExpression binary = (IASTBinaryExpression) expression; // Check for overloaded operator. - IType type1 = getExpressionType(binary.getOperand1()); + IType type1 = binary.getOperand1().getExpressionType(); IType ultimateType1 = SemanticUtil.getUltimateTypeUptoPointers(type1); if (ultimateType1 instanceof IProblemBinding) { return type1; @@ -1934,7 +1934,7 @@ public class CPPVisitor extends ASTQueries { } } } - IType type2 = getExpressionType(binary.getOperand2()); + IType type2 = binary.getOperand2().getExpressionType(); IType ultimateType2 = SemanticUtil.getUltimateTypeUptoPointers(type2); if (ultimateType2 instanceof IProblemBinding) { return type2; @@ -2014,7 +2014,7 @@ public class CPPVisitor extends ASTQueries { return get_type_info(expression); } - IType type = getExpressionType(((IASTUnaryExpression)expression).getOperand()); + IType type= ((IASTUnaryExpression) expression).getOperand().getExpressionType(); while (type instanceof ITypedef) { try { type = ((ITypedef) type).getType(); @@ -2087,7 +2087,7 @@ public class CPPVisitor extends ASTQueries { } } else if (expression instanceof IASTExpressionList) { IASTExpression[] exps = ((IASTExpressionList)expression).getExpressions(); - return getExpressionType(exps[exps.length - 1]); + return exps[exps.length - 1].getExpressionType(); } else if (expression instanceof ICPPASTTypeIdExpression) { ICPPASTTypeIdExpression typeidExp = (ICPPASTTypeIdExpression) expression; switch (typeidExp.getOperator()) { @@ -2098,7 +2098,7 @@ public class CPPVisitor extends ASTQueries { } return createType(typeidExp.getTypeId()); } else if (expression instanceof IASTArraySubscriptExpression) { - IType t = getExpressionType(((IASTArraySubscriptExpression) expression).getArrayExpression()); + IType t = ((IASTArraySubscriptExpression) expression).getArrayExpression().getExpressionType(); try { if (t instanceof ICPPReferenceType) { t = ((ICPPReferenceType)t).getType(); @@ -2127,7 +2127,7 @@ public class CPPVisitor extends ASTQueries { if (statements.length > 0) { IASTStatement st = statements[statements.length - 1]; if (st instanceof IASTExpressionStatement) - return getExpressionType(((IASTExpressionStatement)st).getExpression()); + return ((IASTExpressionStatement) st).getExpression().getExpressionType(); } } else if (expression instanceof IASTConditionalExpression) { final IASTConditionalExpression conditional = (IASTConditionalExpression) expression; @@ -2135,8 +2135,8 @@ public class CPPVisitor extends ASTQueries { if (positiveExpression == null) { positiveExpression= conditional.getLogicalConditionExpression(); } - IType t2 = getExpressionType(positiveExpression); - IType t3 = getExpressionType(conditional.getNegativeResultExpression()); + IType t2 = positiveExpression.getExpressionType(); + IType t3 = conditional.getNegativeResultExpression().getExpressionType(); if (t3 instanceof IPointerType || t2 == null) return t3; return t2; 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 a350aafc572..d036bf05ba8 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 @@ -319,11 +319,11 @@ class LookupData { if (tempNameParent instanceof ICPPASTUnaryExpression) { ICPPASTUnaryExpression unaryExp = (ICPPASTUnaryExpression) tempNameParent; IASTExpression oprd= unaryExp.getOperand(); - return CPPVisitor.getExpressionType(oprd); + return oprd.getExpressionType(); } if (tempNameParent instanceof ICPPASTFieldReference) { ICPPASTFieldReference fieldRef = (ICPPASTFieldReference) tempNameParent; - IType implied = CPPVisitor.getExpressionType(fieldRef.getFieldOwner()); + IType implied = fieldRef.getFieldOwner().getExpressionType(); if (fieldRef.isPointerDereference() && implied instanceof IPointerType) { return ((IPointerType)implied).getType(); } @@ -331,13 +331,13 @@ class LookupData { } if (tempNameParent instanceof IASTArraySubscriptExpression) { IASTExpression exp = ((IASTArraySubscriptExpression)tempNameParent).getArrayExpression(); - return CPPVisitor.getExpressionType(exp); + return exp.getExpressionType(); } if (tempNameParent instanceof IASTFunctionCallExpression) { - return CPPVisitor.getExpressionType(((IASTFunctionCallExpression) tempNameParent).getFunctionNameExpression()); + return ((IASTFunctionCallExpression) tempNameParent).getFunctionNameExpression().getExpressionType(); } if (tempNameParent instanceof IASTBinaryExpression) { - return CPPVisitor.getExpressionType(((IASTBinaryExpression) tempNameParent).getOperand1()); + return ((IASTBinaryExpression) tempNameParent).getOperand1().getExpressionType(); } return null; } |