Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 117293 Details for
Bug 253690
[scalability] Parser needs a lot of memory parsing large initializer expressions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
follow up on the fix
253690-2.txt (text/plain), 10.78 KB, created by
Markus Schorn
on 2008-11-07 03:56:01 EST
(
hide
)
Description:
follow up on the fix
Filename:
MIME Type:
Creator:
Markus Schorn
Created:
2008-11-07 03:56:01 EST
Size:
10.78 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.core >Index: parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java,v >retrieving revision 1.105.2.13 >diff -u -r1.105.2.13 AbstractGNUSourceCodeParser.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java 6 Nov 2008 13:58:55 -0000 1.105.2.13 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java 7 Nov 2008 08:44:58 -0000 >@@ -108,24 +108,6 @@ > } > } > >- protected static class NameChecker extends ASTVisitor { >- private boolean fFound; >- protected NameChecker() { >- shouldVisitNames= true; >- } >- @Override >- public int visit(IASTName name) { >- fFound= true; >- return PROCESS_ABORT; >- } >- public boolean containsName(IASTNode node) { >- fFound= false; >- node.accept(this); >- return fFound; >- } >- } >- protected NameChecker NAME_CHECKER= new NameChecker(); >- > protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4; > protected static int parseCount = 0; > >Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java,v >retrieving revision 1.166.2.18 >diff -u -r1.166.2.18 GNUCPPSourceParser.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 6 Nov 2008 13:58:55 -0000 1.166.2.18 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 7 Nov 2008 08:44:59 -0000 >@@ -146,6 +146,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.ASTNode; >+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; >@@ -3301,7 +3302,7 @@ > // assignmentExpression > IASTExpression assignmentExpression = assignmentExpression(); > if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) { >- if (!NAME_CHECKER.containsName(assignmentExpression)) >+ if (!ASTQueries.canContainName(assignmentExpression)) > return null; > } > >Index: parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java,v >retrieving revision 1.111.2.12 >diff -u -r1.111.2.12 GNUCSourceParser.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 6 Nov 2008 13:58:54 -0000 1.111.2.12 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 7 Nov 2008 08:44:58 -0000 >@@ -111,6 +111,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.ASTNode; >+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; >@@ -189,21 +190,22 @@ > > IASTInitializer initializer = cInitializerClause(newDesignators, true); > >- if (newDesignators.isEmpty()) { >- // depending on value of skipTrivialItemsInCompoundInitializers initializer may be null >- if (initializer != null) >+ // depending on value of skipTrivialItemsInCompoundInitializers initializer may be null >+ if (initializer != null) { >+ if (newDesignators.isEmpty()) { > result.addInitializer(initializer); >- } else { >- ICASTDesignatedInitializer desigInitializer = createDesignatorInitializer(); >- ((ASTNode) desigInitializer).setOffsetAndLength( >- ((ASTNode) newDesignators.get(0)).getOffset(), >- ((ASTNode)initializer).getOffset() + ((ASTNode)initializer).getLength() - ((ASTNode) newDesignators.get(0)).getOffset()); >- for (int i = 0; i < newDesignators.size(); ++i) { >- ICASTDesignator d = (ICASTDesignator) newDesignators.get(i); >- desigInitializer.addDesignator(d); >- } >- desigInitializer.setOperandInitializer(initializer); >- result.addInitializer(desigInitializer); >+ } else { >+ ICASTDesignatedInitializer desigInitializer = createDesignatorInitializer(); >+ ((ASTNode) desigInitializer).setOffsetAndLength( >+ ((ASTNode) newDesignators.get(0)).getOffset(), >+ ((ASTNode)initializer).getOffset() + ((ASTNode)initializer).getLength() - ((ASTNode) newDesignators.get(0)).getOffset()); >+ for (int i = 0; i < newDesignators.size(); ++i) { >+ ICASTDesignator d = (ICASTDesignator) newDesignators.get(i); >+ desigInitializer.addDesignator(d); >+ } >+ desigInitializer.setOperandInitializer(initializer); >+ result.addInitializer(desigInitializer); >+ } > } > // can end with ", }" or "}" > if (LT(1) == IToken.tCOMMA) >@@ -232,7 +234,7 @@ > // assignmentExpression > IASTExpression assignmentExpression = assignmentExpression(); > if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) { >- if (!NAME_CHECKER.containsName(assignmentExpression)) >+ if (!ASTQueries.canContainName(assignmentExpression)) > return null; > } > IASTInitializerExpression result = createInitializerExpression(); >Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java,v >retrieving revision 1.19.2.12 >diff -u -r1.19.2.12 CPPVisitor.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java 26 Oct 2008 22:54:18 -0000 1.19.2.12 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java 7 Nov 2008 08:45:00 -0000 >@@ -151,6 +151,7 @@ > import org.eclipse.cdt.core.parser.util.ArrayUtil; > 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.ITypeContainer; > import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; > import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; >@@ -191,7 +192,7 @@ > /** > * @author aniefer > */ >-public class CPPVisitor { >+public class CPPVisitor extends ASTQueries { > public static final String SIZE_T = "size_t"; //$NON-NLS-1$ > public static final String PTRDIFF_T = "ptrdiff_t"; //$NON-NLS-1$ > public static final String STD = "std"; //$NON-NLS-1$ >Index: parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java >=================================================================== >RCS file: parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java >diff -N parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; >+import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression; >+import org.eclipse.cdt.core.dom.ast.IASTExpression; >+import org.eclipse.cdt.core.dom.ast.IASTExpressionList; >+import org.eclipse.cdt.core.dom.ast.IASTIdExpression; >+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; >+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; >+import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; >+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; >+ >+/** >+ * Base class for {@link CVisitor} and {@link CPPVisitor} >+ */ >+public class ASTQueries { >+ /** >+ * Tests whether the given expression can contain ast-names, suitable to be used before ambiguity >+ * resolution. >+ */ >+ public static boolean canContainName(IASTExpression expr) { >+ if (expr == null || expr instanceof IASTLiteralExpression) >+ return false; >+ >+ if (expr instanceof IASTAmbiguousExpression) >+ return true; >+ if (expr instanceof IASTIdExpression) >+ return true; >+ >+ if (expr instanceof IASTUnaryExpression) { >+ IASTUnaryExpression uexpr= (IASTUnaryExpression) expr; >+ return canContainName(uexpr.getOperand()); >+ } >+ if (expr instanceof IASTBinaryExpression) { >+ IASTBinaryExpression bexpr= (IASTBinaryExpression) expr; >+ return canContainName(bexpr.getOperand1()) || canContainName(bexpr.getOperand2()); >+ } >+ if (expr instanceof IASTConditionalExpression) { >+ IASTConditionalExpression cexpr= (IASTConditionalExpression) expr; >+ return canContainName(cexpr.getLogicalConditionExpression()) || >+ canContainName(cexpr.getPositiveResultExpression()) || canContainName(cexpr.getNegativeResultExpression()); >+ } >+ if (expr instanceof IASTExpressionList) { >+ IASTExpressionList lexpr= (IASTExpressionList) expr; >+ IASTExpression[] subexprs= lexpr.getExpressions(); >+ for (IASTExpression subexpr : subexprs) { >+ if (canContainName(subexpr)) >+ return true; >+ } >+ } >+ return true; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 253690
:
116932
|
117176
|
117193
|
117194
| 117293 |
117297
|
117439