mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 359376: Updating implicit ctors in index.
This commit is contained in:
parent
19175c1f09
commit
7affbb771e
3 changed files with 52 additions and 2 deletions
|
@ -1432,5 +1432,36 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct S {};
|
||||||
|
|
||||||
|
// struct S {S(int){}};
|
||||||
|
public void testImplicitDefaultCtor_Bug359376() throws Exception {
|
||||||
|
setupFile(2, true);
|
||||||
|
fIndex.acquireReadLock();
|
||||||
|
try {
|
||||||
|
final ICPPClassType s = (ICPPClassType) findBinding("S");
|
||||||
|
assertNotNull(s);
|
||||||
|
final ICPPConstructor[] ctors = s.getConstructors();
|
||||||
|
assertEquals(2, ctors.length); // 2 implicit ctors
|
||||||
|
assertTrue(ctors[0].isImplicit());
|
||||||
|
assertTrue(ctors[1].isImplicit());
|
||||||
|
} finally {
|
||||||
|
fIndex.releaseReadLock();
|
||||||
|
}
|
||||||
|
updateFile();
|
||||||
|
|
||||||
|
fIndex.acquireReadLock();
|
||||||
|
try {
|
||||||
|
final ICPPClassType s = (ICPPClassType) findBinding("S");
|
||||||
|
assertNotNull(s);
|
||||||
|
final ICPPConstructor[] ctors = s.getConstructors();
|
||||||
|
assertEquals(2, ctors.length); // 1 explicit and one implicit ctor
|
||||||
|
assertTrue(ctors[0].isImplicit() != ctors[1].isImplicit());
|
||||||
|
} finally {
|
||||||
|
fIndex.releaseReadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -473,6 +475,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
final long fileLocalRec= type.getLocalToFileRec();
|
final long fileLocalRec= type.getLocalToFileRec();
|
||||||
IScope scope = binding.getCompositeScope();
|
IScope scope = binding.getCompositeScope();
|
||||||
if (scope instanceof ICPPClassScope) {
|
if (scope instanceof ICPPClassScope) {
|
||||||
|
List<ICPPMethod> old= new ArrayList<ICPPMethod>();
|
||||||
|
if (type instanceof ICPPClassType) {
|
||||||
|
IScope oldScope = ((ICPPClassType)type).getCompositeScope();
|
||||||
|
if (oldScope instanceof ICPPClassScope) {
|
||||||
|
old.addAll(Arrays.asList(((ICPPClassScope) oldScope).getImplicitMethods()));
|
||||||
|
}
|
||||||
|
}
|
||||||
ICPPMethod[] implicit= ((ICPPClassScope) scope).getImplicitMethods();
|
ICPPMethod[] implicit= ((ICPPClassScope) scope).getImplicitMethods();
|
||||||
for (ICPPMethod method : implicit) {
|
for (ICPPMethod method : implicit) {
|
||||||
if (!(method instanceof IProblemBinding)) {
|
if (!(method instanceof IProblemBinding)) {
|
||||||
|
@ -481,9 +490,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
pdomBinding = createBinding(type, method, fileLocalRec);
|
pdomBinding = createBinding(type, method, fileLocalRec);
|
||||||
} else if (!getPDOM().hasLastingDefinition(pdomBinding)) {
|
} else if (!getPDOM().hasLastingDefinition(pdomBinding)) {
|
||||||
pdomBinding.update(this, method);
|
pdomBinding.update(this, method);
|
||||||
|
old.remove(pdomBinding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (ICPPMethod method : old) {
|
||||||
|
if (method instanceof PDOMBinding)
|
||||||
|
((PDOMBinding) method).update(this, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 QNX Software Systems and others.
|
* Copyright (c) 2006, 2011 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
|
||||||
|
@ -80,7 +80,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
public final void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||||
if (newBinding instanceof ICPPMethod) {
|
if (newBinding instanceof ICPPMethod) {
|
||||||
ICPPMethod method= (ICPPMethod) newBinding;
|
ICPPMethod method= (ICPPMethod) newBinding;
|
||||||
super.update(linkage, newBinding);
|
super.update(linkage, newBinding);
|
||||||
|
@ -92,6 +92,11 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
throw new CoreException(Util.createStatus(e));
|
throw new CoreException(Util.createStatus(e));
|
||||||
}
|
}
|
||||||
|
} else if (newBinding == null && isImplicit()) {
|
||||||
|
// Clear the implicit flag, such that the binding will no longer be picked up.
|
||||||
|
byte annot= (byte) (getAnnotation1() ^ (1 << PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET));
|
||||||
|
getDB().putByte(record + ANNOTATION1, annot);
|
||||||
|
annotation1= annot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue