mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Bug 300019: Using declaration targeting more than two declarations
This commit is contained in:
parent
c5c2bf67b8
commit
85b56d1d8a
3 changed files with 57 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -1154,4 +1154,25 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
||||||
public void testLateDefinitionOfInheritance_Bug292749() throws Exception {
|
public void testLateDefinitionOfInheritance_Bug292749() throws Exception {
|
||||||
getBindingFromASTName("useBase(x.d", 7, ICPPFunction.class);
|
getBindingFromASTName("useBase(x.d", 7, ICPPFunction.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// namespace one {
|
||||||
|
// void fx();
|
||||||
|
// void fx(int);
|
||||||
|
// void fx(int, int);
|
||||||
|
// }
|
||||||
|
// namespace two {
|
||||||
|
// using one::fx;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #include "header.h"
|
||||||
|
// void test() {
|
||||||
|
// two::fx();
|
||||||
|
// two::fx(1);
|
||||||
|
// two::fx(1,1);
|
||||||
|
// }
|
||||||
|
public void testUsingDeclaration_Bug300019() throws Exception {
|
||||||
|
getBindingFromASTName("fx();", 2, ICPPFunction.class);
|
||||||
|
getBindingFromASTName("fx(1);", 2, ICPPFunction.class);
|
||||||
|
getBindingFromASTName("fx(1,1);", 2, ICPPFunction.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2009 QNX Software Systems and others.
|
* Copyright (c) 2006, 2010 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -147,16 +147,16 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
||||||
IBinding[] result = null;
|
IBinding[] result = null;
|
||||||
try {
|
try {
|
||||||
if (!prefixLookup) {
|
if (!prefixLookup) {
|
||||||
return getBindingsViaCache(name.getLookupKey());
|
result= getBindingsViaCache(name.getLookupKey());
|
||||||
|
} else {
|
||||||
|
BindingCollector visitor= new BindingCollector(getLinkage(), name.getLookupKey(),
|
||||||
|
IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, prefixLookup, !prefixLookup);
|
||||||
|
getIndex().accept(visitor);
|
||||||
|
result = visitor.getBindings();
|
||||||
}
|
}
|
||||||
BindingCollector visitor= new BindingCollector(getLinkage(), name.getLookupKey(),
|
|
||||||
IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, prefixLookup, !prefixLookup);
|
|
||||||
getIndex().accept(visitor);
|
|
||||||
IBinding[] bindings = visitor.getBindings();
|
|
||||||
if (fileSet != null) {
|
if (fileSet != null) {
|
||||||
bindings= fileSet.filterFileLocalBindings(bindings);
|
result= fileSet.filterFileLocalBindings(result);
|
||||||
}
|
}
|
||||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, bindings);
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,25 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Google, Inc and others.
|
* Copyright (c) 2008, 2010 Google, Inc and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Sergey Prigogin (Google) - initial API and implementation
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
|
@ -43,14 +48,24 @@ class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclara
|
||||||
public PDOMCPPUsingDeclaration(PDOMLinkage linkage, PDOMNode parent, ICPPUsingDeclaration using)
|
public PDOMCPPUsingDeclaration(PDOMLinkage linkage, PDOMNode parent, ICPPUsingDeclaration using)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
super(linkage, parent, using.getNameCharArray());
|
super(linkage, parent, using.getNameCharArray());
|
||||||
IBinding[] delegates= using.getDelegates();
|
|
||||||
long nextRecord = 0;
|
final Database db = getDB();
|
||||||
for (int i = delegates.length; --i >= 0;) {
|
final char[] name = using.getNameCharArray();
|
||||||
PDOMCPPUsingDeclaration simpleUsing = i > 0 ?
|
Set<PDOMBinding> targets= new LinkedHashSet<PDOMBinding>();
|
||||||
new PDOMCPPUsingDeclaration(linkage, parent, getNameCharArray()) : this;
|
PDOMCPPUsingDeclaration last= null;
|
||||||
simpleUsing.setTargetBinding(parent.getLinkage(), delegates[i]);
|
for (IBinding delegate : using.getDelegates()) {
|
||||||
getDB().putRecPtr(record + NEXT_DELEGATE, nextRecord);
|
PDOMBinding target = getLinkage().adaptBinding(delegate);
|
||||||
nextRecord = simpleUsing.getRecord();
|
if (target != null && targets.add(target)) {
|
||||||
|
if (last == null) {
|
||||||
|
setTargetBinding(linkage, target);
|
||||||
|
last= this;
|
||||||
|
} else {
|
||||||
|
PDOMCPPUsingDeclaration next= new PDOMCPPUsingDeclaration(linkage, parent, name);
|
||||||
|
next.setTargetBinding(linkage, target);
|
||||||
|
db.putRecPtr(last.getRecord() + NEXT_DELEGATE, next.record);
|
||||||
|
last= next;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,9 +77,8 @@ class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclara
|
||||||
super(linkage, parent, name);
|
super(linkage, parent, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTargetBinding(PDOMLinkage linkage, IBinding delegate) throws CoreException {
|
private void setTargetBinding(PDOMLinkage linkage, PDOMBinding delegate) throws CoreException {
|
||||||
PDOMBinding target = getLinkage().adaptBinding(delegate);
|
getDB().putRecPtr(record + TARGET_BINDING, delegate != null ? delegate.getRecord() : 0);
|
||||||
getDB().putRecPtr(record + TARGET_BINDING, target != null ? target.getRecord() : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue