1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 484959 - Instantiate return expression of constexpr function

template

Change-Id: If9f181581924395ba575167b34aca89a88931578
Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
Nathan Ridge 2016-01-03 01:47:44 -05:00
parent 604f391865
commit db27a94a9e
52 changed files with 220 additions and 119 deletions

View file

@ -8752,6 +8752,24 @@ public class AST2TemplateTests extends AST2TestBase {
public void testConstexprFunctionCallWithNonConstexprArguments_429891() throws Exception {
parseAndCheckBindings();
}
// template <typename>
// struct S;
//
// template <>
// struct S<int> {
// static const int value = 42;
// };
//
// template <typename T>
// constexpr int foo() {
// return S<T>::value;
// }
//
// constexpr int waldo = foo<int>();
public void testInstantiationOfReturnExpression_484959() throws Exception {
getAssertionHelper().assertVariableValue("waldo", 42);
}
// template <typename> class A {};
// template <int> class B {};

View file

@ -776,9 +776,7 @@ public class AST2TestBase extends BaseTestCase {
public void assertVariableValue(String variableName, long expectedValue) {
IVariable var = assertNonProblem(variableName);
assertNotNull(var.getInitialValue());
assertNotNull(var.getInitialValue().numericalValue());
assertEquals(expectedValue, var.getInitialValue().numericalValue().longValue());
BaseTestCase.assertVariableValue(var, expectedValue);
}
public <T, U extends T> U assertType(T obj, Class... cs) {

View file

@ -2644,6 +2644,25 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testSpecializationOfConstexprFunction_420995() throws Exception {
checkBindings();
}
// template <typename>
// struct S;
//
// template <>
// struct S<int> {
// static const int value = 42;
// };
//
// template <typename T>
// constexpr int foo() {
// return S<T>::value;
// }
// constexpr int waldo = foo<int>();
public void testInstantiationOfReturnExpression_484959() throws Exception {
ICPPVariable waldo = getBindingFromASTName("waldo", 5);
assertVariableValue(waldo, 42);
}
// template <class TYPE>
// class waldo {

View file

@ -32,6 +32,7 @@ import junit.framework.TestResult;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ElementChangedEvent;
@ -349,4 +350,10 @@ public class BaseTestCase extends TestCase {
}
return clazz.cast(o);
}
protected static void assertVariableValue(IVariable var, long expectedValue) {
assertNotNull(var.getInitialValue());
assertNotNull(var.getInitialValue().numericalValue());
assertEquals(expectedValue, var.getInitialValue().numericalValue().longValue());
}
}

View file

@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
@ -162,7 +163,7 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPDeferr
}
@Override
public ICPPEvaluation getReturnExpression() {
public ICPPEvaluation getReturnExpression(IASTNode point) {
return null;
}
}

View file

@ -673,7 +673,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
}
@Override
public ICPPEvaluation getReturnExpression() {
public ICPPEvaluation getReturnExpression(IASTNode point) {
if (!isConstexpr())
return null;
if (definition == null)
@ -710,9 +710,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
return EvalFixed.INCOMPLETE;
}
public static ICPPEvaluation getReturnExpression(ICPPFunction function) {
public static ICPPEvaluation getReturnExpression(ICPPFunction function, IASTNode point) {
if (function instanceof ICPPComputableFunction) {
return ((ICPPComputableFunction) function).getReturnExpression();
return ((ICPPComputableFunction) function).getReturnExpression(point);
}
return null;
}

View file

@ -35,6 +35,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.index.IIndexBinding;
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.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/**
@ -319,7 +321,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
}
@Override
public ICPPEvaluation getReturnExpression() {
public ICPPEvaluation getReturnExpression(IASTNode point) {
if (!isConstexpr())
return null;
@ -330,7 +332,12 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
}
IBinding f = getSpecializedBinding();
if (f instanceof ICPPComputableFunction) {
return ((ICPPComputableFunction) f).getReturnExpression();
ICPPEvaluation eval = ((ICPPComputableFunction) f).getReturnExpression(point);
if (eval != null) {
eval = eval.instantiate(getTemplateParameterMap(), -1,
CPPTemplates.getSpecializationContext(getOwner()), Value.MAX_RECURSION_DEPTH, point);
}
return eval;
}
return null;
}

View file

@ -438,7 +438,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
}
@Override
public ICPPEvaluation getReturnExpression() {
public ICPPEvaluation getReturnExpression(IASTNode point) {
if (!isConstexpr())
return null;
ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(getDefinition());

View file

@ -39,9 +39,6 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
IValue value = evaluation.getValue(point);
if (value == Value.ERROR) {
fEvaluation = EvalFixed.INCOMPLETE;
} else if (value.getEvaluation() instanceof EvalFixed) {
// Avoid nesting EvalFixed's as nesting causes the signature to be different.
fEvaluation = value.getEvaluation();
} else {
fEvaluation= new EvalFixed(evaluation.getType(point),
evaluation.getValueCategory(point), value);

View file

@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
/**
* Represents a function the return value of which may potentially be calculated at parsing time.
*/
@ -17,6 +19,7 @@ public interface ICPPComputableFunction {
/**
* For a constexpr function returns the return statement expression. Otherwise returns
* {@code null}.
* @param point the point of instantiation for name lookups
*/
public ICPPEvaluation getReturnExpression();
public ICPPEvaluation getReturnExpression(IASTNode point);
}

View file

@ -45,6 +45,14 @@ public class EvalFixed extends CPPEvaluation {
private boolean fCheckedIsValueDependent;
public EvalFixed(IType type, ValueCategory cat, IValue value) {
// Avoid nesting EvalFixed's as nesting causes the signature to be different.
if (value.getEvaluation() instanceof EvalFixed) {
EvalFixed inner = (EvalFixed) value.getEvaluation();
type = inner.fType;
cat = inner.fValueCategory;
value = inner.fValue;
}
if (type instanceof CPPBasicType) {
Long num = value.numericalValue();
if (num != null) {
@ -57,7 +65,7 @@ public class EvalFixed extends CPPEvaluation {
fValueCategory= cat;
fValue= value;
}
public IType getType() {
return fType;
}

View file

@ -244,7 +244,7 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
}
if (function == null)
return this;
ICPPEvaluation eval = CPPFunction.getReturnExpression(function);
ICPPEvaluation eval = CPPFunction.getReturnExpression(function, context.getPoint());
if (eval == null)
return EvalFixed.INCOMPLETE;
CPPFunctionParameterMap parameterMap = buildParameterMap(function);

View file

@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
@ -139,7 +140,7 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction,
}
@Override
public ICPPEvaluation getReturnExpression() {
return CPPFunction.getReturnExpression((ICPPFunction) rbinding);
public ICPPEvaluation getReturnExpression(IASTNode point) {
return CPPFunction.getReturnExpression((ICPPFunction) rbinding, point);
}
}

View file

@ -19,6 +19,7 @@ import java.lang.reflect.Modifier;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
@ -436,9 +437,10 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
/**
* The binding is reused by a declaration or definition, we may need to update modifiers.
* @param point the point of instantiation for name lookups
* @throws CoreException
*/
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
}
@Override

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
@ -62,7 +63,7 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType,
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
storeValueBounds((IEnumeration) newBinding);
}

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType;
@ -64,7 +65,7 @@ class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof IEnumerator)
storeValue(getDB(), (IEnumerator) newBinding);
}

View file

@ -15,6 +15,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
@ -76,7 +77,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
}
@Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(final PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (!(newBinding instanceof IFunction))
return;

View file

@ -114,7 +114,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
if (shouldUpdate(pdomBinding, fromName)) {
IBinding fromBinding = fromName.getBinding();
pdomBinding.update(this, fromBinding);
pdomBinding.update(this, fromBinding, null);
// Update the tags based on the tags from the new binding. This cannot be done in
// PDOMBinding.update, because not all subclasses (e.g., PDOMCFunction) call

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
@ -71,12 +72,12 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ICompositeType) {
ICompositeType ct= (ICompositeType) newBinding;
setKind(ct);
setAnonymous(ct);
super.update(linkage, newBinding);
super.update(linkage, newBinding, point);
}
}

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IType;
@ -55,7 +56,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
}
@Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(final PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ITypedef) {
ITypedef td= (ITypedef) newBinding;
try {

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
@ -66,7 +67,7 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
}
@Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(final PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof IVariable) {
final Database db = getDB();
IVariable var= (IVariable) newBinding;

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.internal.core.pdom.dom.IInternalPDOMNode;
@ -29,7 +30,7 @@ public interface IPDOMCPPTemplateParameter extends IInternalPDOMNode, ICPPTempla
*/
void configure(ICPPTemplateParameter templateParameter);
void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException;
void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException;
/**
* parameters of template template parameters need to be deleted.

View file

@ -89,11 +89,11 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ICPPClassType) {
ICPPClassType classType= (ICPPClassType) newBinding;
setFlags(classType);
super.update(linkage, newBinding);
super.update(linkage, newBinding, point);
}
}

View file

@ -18,6 +18,7 @@ import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
@ -116,8 +117,8 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
super.update(linkage, newBinding);
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
super.update(linkage, newBinding, point);
if (newBinding instanceof ICPPClassTemplate) {
ICPPClassTemplate ct= (ICPPClassTemplate) newBinding;
try {
@ -157,7 +158,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
// Reuse param
result[i]= j;
props[j]= -1;
allParams[j].update(linkage, newPar);
allParams[j].update(linkage, newPar, null);
if (j != i)
reorder= true;
continue outer;

View file

@ -22,6 +22,7 @@ import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IType;
@ -84,13 +85,13 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ICPPClassType) {
ICPPClassType ct= (ICPPClassType) newBinding;
setKind(ct);
setAnonymous(ct);
setFinal(ct);
super.update(linkage, newBinding);
super.update(linkage, newBinding, point);
}
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
@ -20,9 +21,9 @@ import org.eclipse.core.runtime.CoreException;
class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor {
public PDOMCPPConstructor(PDOMCPPLinkage linkage, PDOMNode parent, ICPPConstructor method)
public PDOMCPPConstructor(PDOMCPPLinkage linkage, PDOMNode parent, ICPPConstructor method, IASTNode point)
throws CoreException, DOMException {
super(linkage, parent, method);
super(linkage, parent, method, point);
}
public PDOMCPPConstructor(PDOMLinkage linkage, long record) {

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
@ -29,8 +30,8 @@ public class PDOMCPPConstructorInstance extends PDOMCPPMethodInstance implements
protected static final int RECORD_SIZE = PDOMCPPMethodInstance.RECORD_SIZE + 0;
public PDOMCPPConstructorInstance(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method,
PDOMBinding instantiated) throws CoreException {
super(linkage, parent, method, instantiated);
PDOMBinding instantiated, IASTNode point) throws CoreException {
super(linkage, parent, method, instantiated, point);
}
public PDOMCPPConstructorInstance(PDOMLinkage linkage, long bindingRecord) {

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -27,8 +28,9 @@ class PDOMCPPConstructorSpecialization extends PDOMCPPMethodSpecialization imple
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPMethodSpecialization.RECORD_SIZE + 0;
public PDOMCPPConstructorSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPConstructor constructor, PDOMBinding specialized) throws CoreException {
super(linkage, parent, constructor, specialized);
public PDOMCPPConstructorSpecialization(PDOMCPPLinkage linkage, PDOMNode parent,
ICPPConstructor constructor, PDOMBinding specialized, IASTNode point) throws CoreException {
super(linkage, parent, constructor, specialized, point);
}
public PDOMCPPConstructorSpecialization(PDOMLinkage linkage, long bindingRecord) {

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
@ -22,9 +23,9 @@ import org.eclipse.core.runtime.CoreException;
*/
class PDOMCPPConstructorTemplate extends PDOMCPPMethodTemplate implements ICPPConstructor {
public PDOMCPPConstructorTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPConstructor method)
throws CoreException, DOMException {
super(linkage, parent, method);
public PDOMCPPConstructorTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPConstructor method,
IASTNode point) throws CoreException, DOMException {
super(linkage, parent, method, point);
}
public PDOMCPPConstructorTemplate(PDOMLinkage linkage, long record) {

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -27,8 +28,8 @@ class PDOMCPPConstructorTemplateSpecialization extends PDOMCPPMethodTemplateSpec
protected static final int RECORD_SIZE = PDOMCPPMethodTemplateSpecialization.RECORD_SIZE + 0;
public PDOMCPPConstructorTemplateSpecialization(PDOMCPPLinkage linkage, PDOMNode parent,
ICPPConstructor constructor, PDOMBinding specialized) throws CoreException {
super(linkage, parent, constructor, specialized);
ICPPConstructor constructor, PDOMBinding specialized, IASTNode point) throws CoreException {
super(linkage, parent, constructor, specialized, point);
}
public PDOMCPPConstructorTemplateSpecialization(PDOMLinkage linkage, long bindingRecord) {

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
@ -67,7 +68,7 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IPDOMCPPEnumType, IPD
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
storeProperties((ICPPEnumeration) newBinding);
}

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
@ -74,7 +75,7 @@ class PDOMCPPEnumerationSpecialization extends PDOMCPPSpecialization
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
storeProperties((ICPPEnumeration) newBinding);
}

View file

@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType;
@ -65,7 +66,7 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IPDOMCPPEnumerator {
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof IEnumerator) {
IValue value= ((IEnumerator) newBinding).getValue();
if (value != null) {

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType;
@ -65,7 +66,7 @@ class PDOMCPPEnumeratorSpecialization extends PDOMCPPSpecialization implements I
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof IEnumerator) {
IValue value= ((IEnumerator) newBinding).getValue();
if (value != null) {

View file

@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
@ -92,7 +93,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
public PDOMCPPFunction(PDOMCPPLinkage linkage, PDOMNode parent, ICPPFunction function,
boolean setTypes) throws CoreException, DOMException {
boolean setTypes, IASTNode point) throws CoreException, DOMException {
super(linkage, parent, function.getNameCharArray());
Database db = getDB();
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
@ -100,7 +101,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
db.putShort(record + ANNOTATION, getAnnotation(function));
db.putShort(record + REQUIRED_ARG_COUNT, (short) function.getRequiredArgumentCount());
if (setTypes) {
linkage.new ConfigureFunction(function, this);
linkage.new ConfigureFunction(function, this, point);
}
}
@ -131,7 +132,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
@Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(final PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (!(newBinding instanceof ICPPFunction))
return;
@ -184,7 +185,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
if (oldRec != 0) {
PDOMCPPTypeList.clearTypes(this, oldRec);
}
linkage.storeEvaluation(record + RETURN_EXPRESSION, CPPFunction.getReturnExpression(func));
linkage.storeEvaluation(record + RETURN_EXPRESSION, CPPFunction.getReturnExpression(func, point));
}
private void storeExceptionSpec(IType[] exceptionSpec) throws CoreException {
@ -415,7 +416,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
@Override
public ICPPEvaluation getReturnExpression() {
public ICPPEvaluation getReturnExpression(IASTNode point) {
if (!isConstexpr())
return null;

View file

@ -14,6 +14,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionInstance;
@ -39,9 +40,9 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPFunctionSpecialization.RECORD_SIZE + 8;
public PDOMCPPFunctionInstance(PDOMCPPLinkage linkage, PDOMNode parent, ICPPFunction function, PDOMBinding orig)
throws CoreException {
super(linkage, parent, function, orig);
public PDOMCPPFunctionInstance(PDOMCPPLinkage linkage, PDOMNode parent, ICPPFunction function,
PDOMBinding orig, IASTNode point) throws CoreException {
super(linkage, parent, function, orig, point);
final Database db = getDB();
long exceptSpecRec = PDOMCPPTypeList.putTypes(this, function.getExceptionSpecification());

View file

@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
@ -84,7 +85,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization
private int fRequiredArgCount= -1;
public PDOMCPPFunctionSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPFunction astFunction,
PDOMBinding specialized) throws CoreException {
PDOMBinding specialized, IASTNode point) throws CoreException {
super(linkage, parent, (ICPPSpecialization) astFunction, specialized);
Database db = getDB();
@ -129,7 +130,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization
typelist = PDOMCPPTypeList.putTypes(this, astFunction.getExceptionSpecification());
}
db.putRecPtr(record + EXCEPTION_SPEC, typelist);
linkage.new ConfigureFunctionSpecialization(astFunction, this);
linkage.new ConfigureFunctionSpecialization(astFunction, this, point);
}
private short getAnnotation(ICPPFunction astFunction) {
@ -329,7 +330,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization
}
@Override
public ICPPEvaluation getReturnExpression() {
public ICPPEvaluation getReturnExpression(IASTNode point) {
if (!isConstexpr())
return null;

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
@ -42,15 +43,15 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
private volatile IPDOMCPPTemplateParameter[] params; // Cached template parameters.
public PDOMCPPFunctionTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPFunctionTemplate template)
throws CoreException, DOMException {
super(linkage, parent, template, false);
public PDOMCPPFunctionTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPFunctionTemplate template,
IASTNode point) throws CoreException, DOMException {
super(linkage, parent, template, false, point);
final ICPPTemplateParameter[] origParams= template.getTemplateParameters();
params = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
final Database db = getDB();
long rec= PDOMTemplateParameterArray.putArray(db, params);
db.putRecPtr(record + TEMPLATE_PARAMS, rec);
linkage.new ConfigureFunctionTemplate(template, this);
linkage.new ConfigureFunctionTemplate(template, this, point);
}
public PDOMCPPFunctionTemplate(PDOMLinkage linkage, long bindingRecord) {
@ -58,7 +59,7 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
}
@Override
public void update(PDOMLinkage linkage, IBinding name) {
public void update(PDOMLinkage linkage, IBinding name, IASTNode point) {
// no support for updating templates, yet.
}

View file

@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
@ -32,8 +33,8 @@ class PDOMCPPFunctionTemplateSpecialization extends PDOMCPPFunctionSpecializatio
implements ICPPFunctionTemplate, ICPPInstanceCache, IPDOMMemberOwner {
public PDOMCPPFunctionTemplateSpecialization(PDOMCPPLinkage linkage, PDOMNode parent,
ICPPFunctionTemplate template, PDOMBinding specialized) throws CoreException {
super(linkage, parent, template, specialized);
ICPPFunctionTemplate template, PDOMBinding specialized, IASTNode point) throws CoreException {
super(linkage, parent, template, specialized, point);
}
public PDOMCPPFunctionTemplateSpecialization(PDOMLinkage linkage, long bindingRecord) {

View file

@ -232,7 +232,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
}
}
class ConfigureFunction implements Runnable {
private final PDOMCPPFunction fFunction;
private final ICPPFunctionType fOriginalFunctionType;
@ -240,12 +240,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
private final IType[] fOriginalExceptionSpec;
private final ICPPEvaluation fReturnExpression;
public ConfigureFunction(ICPPFunction original, PDOMCPPFunction function) throws DOMException {
public ConfigureFunction(ICPPFunction original, PDOMCPPFunction function, IASTNode point)
throws DOMException {
fFunction = function;
fOriginalFunctionType= original.getType();
fOriginalParameters= original.getParameters();
fOriginalExceptionSpec= function.extractExceptionSpec(original);
fReturnExpression= CPPFunction.getReturnExpression(original);
fReturnExpression= CPPFunction.getReturnExpression(original, point);
postProcesses.add(this);
}
@ -260,9 +261,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
private final PDOMCPPFunctionSpecialization fSpec;
private final ICPPEvaluation fReturnExpression;
public ConfigureFunctionSpecialization(ICPPFunction original, PDOMCPPFunctionSpecialization spec) {
public ConfigureFunctionSpecialization(ICPPFunction original, PDOMCPPFunctionSpecialization spec,
IASTNode point) {
fSpec = spec;
fReturnExpression = CPPFunction.getReturnExpression(original);
fReturnExpression = CPPFunction.getReturnExpression(original, point);
postProcesses.add(this);
}
@ -297,14 +299,15 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
private final IType[] fOriginalExceptionSpec;
private final ICPPEvaluation fReturnExpression;
public ConfigureFunctionTemplate(ICPPFunctionTemplate original, PDOMCPPFunctionTemplate template) throws DOMException {
public ConfigureFunctionTemplate(ICPPFunctionTemplate original, PDOMCPPFunctionTemplate template,
IASTNode point) throws DOMException {
fTemplate = template;
fTemplateParameters= template.getTemplateParameters();
fOriginalTemplateParameters= original.getTemplateParameters();
fOriginalFunctionType= original.getType();
fOriginalParameters= original.getParameters();
fOriginalExceptionSpec= template.extractExceptionSpec(original);
fReturnExpression= CPPFunction.getReturnExpression(original);
fReturnExpression= CPPFunction.getReturnExpression(original, point);
postProcesses.add(this);
}
@ -435,7 +438,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
pdomBinding = adaptBinding(parent, binding, fileLocalRec);
if (pdomBinding == null) {
try {
pdomBinding = createBinding(parent, binding, fileLocalRec[0]);
pdomBinding = createBinding(parent, binding, fileLocalRec[0], fromName);
if (pdomBinding != null) {
getPDOM().putCachedResult(inputBinding, pdomBinding);
if (inputBinding instanceof CPPClosureType) {
@ -458,7 +461,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (shouldUpdate(pdomBinding, fromName)) {
IBinding fromBinding = fromName.getBinding();
pdomBinding.update(this, fromBinding);
pdomBinding.update(this, fromBinding, null);
// Update the tags based on the tags from the new binding. This cannot be done in
// PDOMBinding.update, because not all subclasses (e.g., PDOMCPPFunction) call
@ -498,7 +501,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return false;
}
PDOMBinding createBinding(PDOMNode parent, IBinding binding, long fileLocalRec) throws CoreException, DOMException {
PDOMBinding createBinding(PDOMNode parent, IBinding binding, long fileLocalRec, IASTNode point)
throws CoreException, DOMException {
PDOMBinding pdomBinding= null;
PDOMNode parent2= null;
@ -514,7 +518,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (pdomSpecialized == null)
return null;
pdomBinding = createSpecialization(parent, pdomSpecialized, binding);
pdomBinding = createSpecialization(parent, pdomSpecialized, binding, point);
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
ICPPClassTemplate primary = ((ICPPClassTemplatePartialSpecialization) binding).getPrimaryClassTemplate();
PDOMBinding pdomPrimary = addBinding(primary, null);
@ -542,22 +546,22 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
pdomBinding = new PDOMCPPVariable(this, parent, var);
} else if (binding instanceof ICPPFunctionTemplate) {
if (binding instanceof ICPPConstructor) {
pdomBinding= new PDOMCPPConstructorTemplate(this, parent, (ICPPConstructor) binding);
pdomBinding= new PDOMCPPConstructorTemplate(this, parent, (ICPPConstructor) binding, point);
} else if (binding instanceof ICPPMethod) {
pdomBinding= new PDOMCPPMethodTemplate(this, parent, (ICPPMethod) binding);
pdomBinding= new PDOMCPPMethodTemplate(this, parent, (ICPPMethod) binding, point);
} else if (binding instanceof ICPPFunction) {
pdomBinding= new PDOMCPPFunctionTemplate(this, parent, (ICPPFunctionTemplate) binding);
pdomBinding= new PDOMCPPFunctionTemplate(this, parent, (ICPPFunctionTemplate) binding, point);
}
} else if (binding instanceof ICPPConstructor) {
if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) {
pdomBinding = new PDOMCPPConstructor(this, parent, (ICPPConstructor) binding);
pdomBinding = new PDOMCPPConstructor(this, parent, (ICPPConstructor) binding, point);
}
} else if (binding instanceof ICPPMethod) {
if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) {
pdomBinding = new PDOMCPPMethod(this, parent, (ICPPMethod) binding);
pdomBinding = new PDOMCPPMethod(this, parent, (ICPPMethod) binding, point);
}
} else if (binding instanceof ICPPFunction) {
pdomBinding = new PDOMCPPFunction(this, parent, (ICPPFunction) binding, true);
pdomBinding = new PDOMCPPFunction(this, parent, (ICPPFunction) binding, true, point);
} else if (binding instanceof ICPPNamespaceAlias) {
pdomBinding = new PDOMCPPNamespaceAlias(this, parent, (ICPPNamespaceAlias) binding);
} else if (binding instanceof ICPPNamespace) {
@ -653,16 +657,16 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
}
private PDOMBinding createSpecialization(PDOMNode parent, PDOMBinding orig, IBinding special)
throws CoreException, DOMException {
private PDOMBinding createSpecialization(PDOMNode parent, PDOMBinding orig, IBinding special,
IASTNode point) throws CoreException, DOMException {
PDOMBinding result= null;
if (special instanceof ICPPTemplateInstance) {
if (special instanceof ICPPConstructor && orig instanceof ICPPConstructor) {
result= new PDOMCPPConstructorInstance(this, parent, (ICPPConstructor) special, orig);
result= new PDOMCPPConstructorInstance(this, parent, (ICPPConstructor) special, orig, point);
} else if (special instanceof ICPPMethod && orig instanceof ICPPMethod) {
result= new PDOMCPPMethodInstance(this, parent, (ICPPMethod) special, orig);
result= new PDOMCPPMethodInstance(this, parent, (ICPPMethod) special, orig, point);
} else if (special instanceof ICPPFunction && orig instanceof ICPPFunction) {
result= new PDOMCPPFunctionInstance(this, parent, (ICPPFunction) special, orig);
result= new PDOMCPPFunctionInstance(this, parent, (ICPPFunction) special, orig, point);
} else if (special instanceof ICPPClassType && orig instanceof ICPPClassType) {
result= new PDOMCPPClassInstance(this, parent, (ICPPClassType) special, orig);
}
@ -670,11 +674,11 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
result= new PDOMCPPFieldSpecialization(this, parent, (ICPPField) special, orig);
} else if (special instanceof ICPPFunctionTemplate) {
if (special instanceof ICPPConstructor) {
result= new PDOMCPPConstructorTemplateSpecialization(this, parent, (ICPPConstructor) special, orig);
result= new PDOMCPPConstructorTemplateSpecialization(this, parent, (ICPPConstructor) special, orig, point);
} else if (special instanceof ICPPMethod) {
result= new PDOMCPPMethodTemplateSpecialization(this, parent, (ICPPMethod) special, orig);
result= new PDOMCPPMethodTemplateSpecialization(this, parent, (ICPPMethod) special, orig, point);
} else if (special instanceof ICPPFunction) {
result= new PDOMCPPFunctionTemplateSpecialization(this, parent, (ICPPFunctionTemplate) special, orig);
result= new PDOMCPPFunctionTemplateSpecialization(this, parent, (ICPPFunctionTemplate) special, orig, point);
}
} else if (special instanceof ICPPClassTemplatePartialSpecialization) {
ICPPClassTemplatePartialSpecialization partialSpecSpec = (ICPPClassTemplatePartialSpecialization) special;
@ -685,11 +689,11 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
partialSpecSpec, (PDOMCPPClassTemplateSpecialization) pdomPrimarySpec);
}
} else if (special instanceof ICPPConstructor) {
result= new PDOMCPPConstructorSpecialization(this, parent, (ICPPConstructor) special, orig);
result= new PDOMCPPConstructorSpecialization(this, parent, (ICPPConstructor) special, orig, point);
} else if (special instanceof ICPPMethod) {
result= new PDOMCPPMethodSpecialization(this, parent, (ICPPMethod) special, orig);
result= new PDOMCPPMethodSpecialization(this, parent, (ICPPMethod) special, orig, point);
} else if (special instanceof ICPPFunction) {
result= new PDOMCPPFunctionSpecialization(this, parent, (ICPPFunction) special, orig);
result= new PDOMCPPFunctionSpecialization(this, parent, (ICPPFunction) special, orig, point);
} else if (special instanceof ICPPClassTemplate) {
result= new PDOMCPPClassTemplateSpecialization(this, parent, (ICPPClassTemplate) special, orig);
} else if (special instanceof ICPPClassType) {
@ -721,9 +725,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (!(method instanceof IProblemBinding)) {
PDOMBinding pdomBinding= adaptBinding(method);
if (pdomBinding == null) {
pdomBinding = createBinding(type, method, fileLocalRec);
pdomBinding = createBinding(type, method, fileLocalRec, point);
} else if (!getPDOM().hasLastingDefinition(pdomBinding)) {
pdomBinding.update(this, method);
pdomBinding.update(this, method, null);
old.remove(pdomBinding);
// Update the tags based on the tags from the new binding. This was in
@ -735,7 +739,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
for (ICPPMethod method : old) {
if (method instanceof PDOMBinding)
((PDOMBinding) method).update(this, null);
((PDOMBinding) method).update(this, null, null);
}
}
} catch (DOMException e) {

View file

@ -63,8 +63,9 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
private byte annotation1= -1;
public PDOMCPPMethod(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method) throws CoreException, DOMException {
super(linkage, parent, method, true);
public PDOMCPPMethod(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method, IASTNode point)
throws CoreException, DOMException {
super(linkage, parent, method, true, point);
Database db = getDB();
@ -81,10 +82,10 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
@Override
public final void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public final void update(final PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ICPPMethod) {
ICPPMethod method= (ICPPMethod) newBinding;
super.update(linkage, newBinding);
super.update(linkage, newBinding, point);
annotation1= -1;
try {
final byte annot = PDOMCPPAnnotation.encodeExtraAnnotation(method);

View file

@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
@ -30,9 +31,9 @@ class PDOMCPPMethodInstance extends PDOMCPPFunctionInstance implements ICPPMetho
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPFunctionInstance.RECORD_SIZE + 0;
public PDOMCPPMethodInstance(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method, PDOMBinding instantiated)
throws CoreException {
super(linkage, parent, method, instantiated);
public PDOMCPPMethodInstance(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method,
PDOMBinding instantiated, IASTNode point) throws CoreException {
super(linkage, parent, method, instantiated, point);
}
public PDOMCPPMethodInstance(PDOMLinkage linkage, long bindingRecord) {

View file

@ -51,8 +51,9 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
*/
private static final int CV_OFFSET = PDOMCPPAnnotation.MAX_EXTRA_OFFSET + 1;
public PDOMCPPMethodSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method, PDOMBinding specialized) throws CoreException {
super(linkage, parent, method, specialized);
public PDOMCPPMethodSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method,
PDOMBinding specialized, IASTNode point) throws CoreException {
super(linkage, parent, method, specialized, point);
Database db = getDB();
try {

View file

@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
@ -49,9 +50,9 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
private byte annotation1= -1;
public PDOMCPPMethodTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method)
public PDOMCPPMethodTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method, IASTNode point)
throws CoreException, DOMException {
super(linkage, parent, (ICPPFunctionTemplate) method);
super(linkage, parent, (ICPPFunctionTemplate) method, point);
Database db = getDB();

View file

@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
@ -40,8 +41,8 @@ class PDOMCPPMethodTemplateSpecialization extends PDOMCPPFunctionTemplateSpecial
private volatile IPDOMCPPTemplateParameter[] fTemplateParameters;
public PDOMCPPMethodTemplateSpecialization(PDOMCPPLinkage linkage, PDOMNode parent,
ICPPMethod method, PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPFunctionTemplate) method, specialized);
ICPPMethod method, PDOMBinding specialized, IASTNode point) throws CoreException {
super(linkage, parent, (ICPPFunctionTemplate) method, specialized, point);
computeTemplateParameters((ICPPFunctionTemplate) method); // Sets fTemplateParameters
final Database db = getDB();
long rec = PDOMTemplateParameterArray.putArray(db, fTemplateParameters);

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
@ -76,7 +77,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
updateFlag((ICPPNamespace) newBinding);
}

View file

@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
@ -43,7 +44,7 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias
}
@Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(final PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ICPPNamespaceAlias) {
ICPPNamespaceAlias alias= (ICPPNamespaceAlias) newBinding;
IBinding newTarget= alias.getBinding();

View file

@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
@ -81,7 +82,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ICPPTemplateNonTypeParameter) {
ICPPTemplateNonTypeParameter ntp= (ICPPTemplateNonTypeParameter) newBinding;
updateName(newBinding.getNameCharArray());

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -201,7 +202,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ICPPTemplateTemplateParameter) {
final Database db = getDB();
ICPPTemplateTemplateParameter ttp= (ICPPTemplateTemplateParameter) newBinding;

View file

@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
@ -185,7 +186,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ICPPTemplateTypeParameter) {
ICPPTemplateTypeParameter ttp= (ICPPTemplateTypeParameter) newBinding;
updateName(newBinding.getNameCharArray());

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IType;
@ -47,7 +48,7 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
}
@Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(final PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof ITypedef) {
ITypedef td= (ITypedef) newBinding;
setType(linkage, td.getType());

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
@ -55,7 +56,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
}
@Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
public void update(final PDOMLinkage linkage, IBinding newBinding, IASTNode point) throws CoreException {
if (newBinding instanceof IVariable) {
final Database db = getDB();
IVariable var= (IVariable) newBinding;