Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2007-03-26 16:19:47 -0400
committerDoug Schaefer2007-03-26 16:19:47 -0400
commit9afac2da1b458e9c66803f1550e98fd2f7ff8421 (patch)
treefde65c8d31b0928d53f7a06841aa96b589dc1797
parent5b008e064ad6c2be949a46a14a8d48387b7966a0 (diff)
downloadorg.eclipse.cdt-9afac2da1b458e9c66803f1550e98fd2f7ff8421.tar.gz
org.eclipse.cdt-9afac2da1b458e9c66803f1550e98fd2f7ff8421.tar.xz
org.eclipse.cdt-9afac2da1b458e9c66803f1550e98fd2f7ff8421.zip
Bug 179380 - fix stack overflow in PDOMCPPNamespace.
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java
index 3c68fcc4534..07499a59f2f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java
@@ -11,6 +11,8 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
+import java.util.LinkedList;
+
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
@@ -44,6 +46,8 @@ public class PDOMCPPNamespace extends PDOMBinding
private static final int INDEX_OFFSET = PDOMBinding.RECORD_SIZE + 0;
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
+
+ private String[] qualifiedName;
public PDOMCPPNamespace(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
super(pdom, parent, name);
@@ -88,7 +92,23 @@ public class PDOMCPPNamespace extends PDOMBinding
}
public String[] getQualifiedName() throws DOMException {
- throw new PDOMNotImplementedError();
+ if (qualifiedName == null) {
+ LinkedList namelist = new LinkedList();
+ namelist.addFirst(getName());
+
+ try {
+ PDOMNode parent = getParentNode();
+ while (parent instanceof PDOMCPPNamespace) {
+ namelist.addFirst(((PDOMCPPNamespace)parent).getName());
+ parent = parent.getParentNode();
+ }
+ } catch (CoreException e) {
+ }
+
+ qualifiedName = (String[])namelist.toArray(new String[namelist.size()]);
+ }
+
+ return qualifiedName;
}
public char[][] getQualifiedNameCharArray() throws DOMException {
@@ -142,8 +162,14 @@ public class PDOMCPPNamespace extends PDOMBinding
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
try {
if (name instanceof ICPPASTQualifiedName) {
- IASTName lastName = ((ICPPASTQualifiedName)name).getLastName();
- return lastName != null ? lastName.resolveBinding() : null;
+ String[] myname = getQualifiedName();
+ IASTName[] names = ((ICPPASTQualifiedName)name).getNames();
+ if (myname.length != names.length - 1 || names.length < 2)
+ return null;
+ for (int i = 0; i < myname.length; ++i)
+ if (!myname[i].equals(new String(names[i].toCharArray())))
+ return null;
+ name = names[names.length - 2]; // or myname.length - 1
}
IASTNode parent = name.getParent();
if (parent instanceof ICPPASTQualifiedName) {

Back to the top