mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 395238. Evaluation of constexpr functions. Also few fixes related to
alias templates.
This commit is contained in:
parent
cef7aea253
commit
984c5eb604
48 changed files with 1292 additions and 227 deletions
|
@ -6774,4 +6774,105 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
public void testAliasTemplate_395026_2() throws Exception {
|
public void testAliasTemplate_395026_2() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename U>
|
||||||
|
// struct A {
|
||||||
|
// typedef U type1;
|
||||||
|
//
|
||||||
|
// template<typename V>
|
||||||
|
// struct rebind {
|
||||||
|
// typedef A<V> other;
|
||||||
|
// };
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T, typename U>
|
||||||
|
// struct B {
|
||||||
|
// template<typename T2, typename U2>
|
||||||
|
// static constexpr bool test(typename T2::template rebind<U2>::other*) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// template<typename, typename>
|
||||||
|
// static constexpr bool test(...) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// static const bool value = test<T, U>(nullptr);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T, typename U, bool = B<T, U>::value>
|
||||||
|
// struct C;
|
||||||
|
//
|
||||||
|
// template<typename T, typename U>
|
||||||
|
// struct C<T, U, true> {
|
||||||
|
// typedef typename T::template rebind<U>::other type2;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// struct D {
|
||||||
|
// typedef typename T::type1 type3;
|
||||||
|
//
|
||||||
|
// template<typename U>
|
||||||
|
// using rebind2 = typename C<T, U>::type2;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// struct E : D<T> {
|
||||||
|
// typedef D<T> Base;
|
||||||
|
// typedef typename Base::type3& type4;
|
||||||
|
//
|
||||||
|
// template<typename U>
|
||||||
|
// struct rebind {
|
||||||
|
// typedef typename Base::template rebind2<U> other;
|
||||||
|
// };
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename U, typename T = A<U>>
|
||||||
|
// struct F {
|
||||||
|
// typedef typename E<T>::template rebind<U>::other type5;
|
||||||
|
// typedef typename E<type5>::type4 type6;
|
||||||
|
// type6 operator[](int n);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void f(int);
|
||||||
|
//
|
||||||
|
// void test() {
|
||||||
|
// F<int*> a;
|
||||||
|
// f(*a[0]);
|
||||||
|
// }
|
||||||
|
public void testConstexprFunction_395238_1() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
// template<typename T>
|
||||||
|
// struct A {
|
||||||
|
// template<typename U>
|
||||||
|
// static constexpr U test(U v) {
|
||||||
|
// return v;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// template<typename>
|
||||||
|
// static constexpr bool test(...) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// static const bool value = test<T>(true);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T, bool = A<T>::value>
|
||||||
|
// struct B;
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// struct B<T, true> {
|
||||||
|
// typedef T type;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// B<bool>::type x;
|
||||||
|
// B<int*>::type y;
|
||||||
|
public void testConstexprFunction_395238_2() throws Exception {
|
||||||
|
BindingAssertionHelper ah = getAssertionHelper();
|
||||||
|
ITypedef td = ah.assertNonProblem("B<bool>::type", "type", ITypedef.class);
|
||||||
|
assertEquals("bool", ASTTypeUtil.getType(td.getType()));
|
||||||
|
ah.assertProblem("B<int*>::type", "type");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2061,4 +2061,104 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
public void testAliasTemplate() throws Exception {
|
public void testAliasTemplate() throws Exception {
|
||||||
checkBindings();
|
checkBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename U>
|
||||||
|
// struct A {
|
||||||
|
// typedef U type1;
|
||||||
|
//
|
||||||
|
// template<typename V>
|
||||||
|
// struct rebind {
|
||||||
|
// typedef A<V> other;
|
||||||
|
// };
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T, typename U>
|
||||||
|
// struct B {
|
||||||
|
// template<typename T2, typename U2>
|
||||||
|
// static constexpr bool test(typename T2::template rebind<U2>::other*) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// template<typename, typename>
|
||||||
|
// static constexpr bool test(...) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// static const bool value = test<T, U>(nullptr);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T, typename U, bool = B<T, U>::value>
|
||||||
|
// struct C;
|
||||||
|
//
|
||||||
|
// template<typename T, typename U>
|
||||||
|
// struct C<T, U, true> {
|
||||||
|
// typedef typename T::template rebind<U>::other type2;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T1>
|
||||||
|
// struct D {
|
||||||
|
// typedef typename T1::type1 type3;
|
||||||
|
//
|
||||||
|
// template<typename U1>
|
||||||
|
// using rebind2 = typename C<T1, U1>::type2;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// struct E : D<T> {
|
||||||
|
// typedef D<T> Base;
|
||||||
|
// typedef typename Base::type3& type4;
|
||||||
|
//
|
||||||
|
// template<typename U>
|
||||||
|
// struct rebind {
|
||||||
|
// typedef typename Base::template rebind2<U> other;
|
||||||
|
// };
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename U, typename T = A<U>>
|
||||||
|
// struct F {
|
||||||
|
// typedef typename E<T>::template rebind<U>::other type5;
|
||||||
|
// typedef typename E<type5>::type4 type6;
|
||||||
|
// type6 operator[](int n);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void f(int);
|
||||||
|
|
||||||
|
// void test() {
|
||||||
|
// F<int*> a;
|
||||||
|
// f(*a[0]);
|
||||||
|
// }
|
||||||
|
public void testConstexprFunction_395238_1() throws Exception {
|
||||||
|
checkBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
// template<typename T>
|
||||||
|
// struct A {
|
||||||
|
// template<typename U>
|
||||||
|
// static constexpr U test(U v) {
|
||||||
|
// return v;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// template<typename>
|
||||||
|
// static constexpr bool test(...) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// static const bool value = test<T>(true);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T, bool = A<T>::value>
|
||||||
|
// struct B;
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// struct B<T, true> {
|
||||||
|
// typedef T type;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// B<bool>::type x;
|
||||||
|
// B<int*>::type y;
|
||||||
|
public void testConstexprFunction_395238_2() throws Exception {
|
||||||
|
ITypedef td = getBindingFromASTName("type x", 4, ITypedef.class);
|
||||||
|
assertEquals("bool", ASTTypeUtil.getType(td.getType()));
|
||||||
|
getProblemFromASTName("type y", 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation 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
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
@ -38,6 +39,12 @@ public interface ICPPFunction extends IFunction, ICPPBinding {
|
||||||
*/
|
*/
|
||||||
public boolean isExternC();
|
public boolean isExternC();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this function is declared constexpr.
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
*/
|
||||||
|
public boolean isConstexpr();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the exception specification for this function or <code>null</code> if there
|
* Returns the exception specification for this function or <code>null</code> if there
|
||||||
* is no exception specification.
|
* is no exception specification.
|
||||||
|
|
|
@ -55,7 +55,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||||
|
@ -355,6 +354,7 @@ public class Value implements IValue {
|
||||||
return VALUE_CANNOT_BE_DETERMINED;
|
return VALUE_CANNOT_BE_DETERMINED;
|
||||||
return sizeAndAlignment.size;
|
return sizeAndAlignment.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether the value is a template parameter (or a parameter pack).
|
* Tests whether the value is a template parameter (or a parameter pack).
|
||||||
*
|
*
|
||||||
|
@ -364,10 +364,7 @@ public class Value implements IValue {
|
||||||
public static int isTemplateParameter(IValue tval) {
|
public static int isTemplateParameter(IValue tval) {
|
||||||
ICPPEvaluation eval = tval.getEvaluation();
|
ICPPEvaluation eval = tval.getEvaluation();
|
||||||
if (eval instanceof EvalBinding) {
|
if (eval instanceof EvalBinding) {
|
||||||
IBinding binding = ((EvalBinding) eval).getBinding();
|
return ((EvalBinding) eval).getTemplateParameterID();
|
||||||
if (binding instanceof ICPPTemplateParameter) {
|
|
||||||
return ((ICPPTemplateParameter) binding).getParameterID();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Thomas Corbat (IFS) - Initial API and implementation
|
* Thomas Corbat (IFS) - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -28,7 +29,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
public class CPPAliasTemplate extends PlatformObject implements ICPPAliasTemplate {
|
public class CPPAliasTemplate extends PlatformObject
|
||||||
|
implements ICPPAliasTemplate, ICPPTemplateParameterOwner {
|
||||||
private final IASTName aliasName;
|
private final IASTName aliasName;
|
||||||
private final IType aliasedType;
|
private final IType aliasedType;
|
||||||
private ICPPTemplateParameter[] templateParameters;
|
private ICPPTemplateParameter[] templateParameters;
|
||||||
|
@ -128,4 +130,16 @@ public class CPPAliasTemplate extends PlatformObject implements ICPPAliasTemplat
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
|
return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) {
|
||||||
|
int pos= templateParameter.getParameterPosition();
|
||||||
|
|
||||||
|
ICPPASTTemplateParameter[] params = CPPTemplates.getTemplateDeclaration(aliasName).getTemplateParameters();
|
||||||
|
if (pos < params.length) {
|
||||||
|
final IASTName oName = CPPTemplates.getTemplateParameterName(params[pos]);
|
||||||
|
return oName.resolvePreBinding();
|
||||||
|
}
|
||||||
|
return templateParameter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,11 @@ public class CPPClassSpecialization extends CPPSpecialization
|
||||||
public boolean isFinal() {
|
public boolean isFinal() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConstexpr() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPClassSpecializationScope specScope;
|
private ICPPClassSpecializationScope specScope;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
* Represents a reference to a (member) function (instance), which cannot be resolved because
|
* Represents a reference to a (member) function (instance), which cannot be resolved because
|
||||||
* an argument depends on a template parameter. A compiler would resolve it during instantiation.
|
* an argument depends on a template parameter. A compiler would resolve it during instantiation.
|
||||||
*/
|
*/
|
||||||
public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction {
|
public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction, ICPPComputableFunction {
|
||||||
private static final ICPPFunctionType FUNCTION_TYPE=
|
private static final ICPPFunctionType FUNCTION_TYPE=
|
||||||
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
|
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
|
||||||
|
|
||||||
|
@ -69,6 +70,11 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConstexpr() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IScope getFunctionScope() {
|
public IScope getFunctionScope() {
|
||||||
return asScope();
|
return asScope();
|
||||||
|
@ -128,4 +134,9 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
return fOwner;
|
return fOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation getReturnExpression() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,19 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
@ -38,6 +42,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
|
@ -52,6 +57,7 @@ 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.ASTQueries;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
|
@ -230,17 +236,8 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
||||||
IASTName n = getASTName();
|
IASTName n = getASTName();
|
||||||
IScope scope = CPPVisitor.getContainingScope(n);
|
IScope scope = CPPVisitor.getContainingScope(n);
|
||||||
if (scope instanceof ICPPClassScope) {
|
if (scope instanceof ICPPClassScope) {
|
||||||
ICPPASTDeclSpecifier declSpec = null;
|
ICPPASTDeclSpecifier declSpec = getDeclSpecifier();
|
||||||
if (definition != null) {
|
if (declSpec != null && declSpec.isFriend()) {
|
||||||
IASTNode node = ASTQueries.findOutermostDeclarator(definition).getParent();
|
|
||||||
IASTFunctionDefinition def = (IASTFunctionDefinition) node;
|
|
||||||
declSpec = (ICPPASTDeclSpecifier) def.getDeclSpecifier();
|
|
||||||
} else {
|
|
||||||
IASTNode node = ASTQueries.findOutermostDeclarator(declarations[0]).getParent();
|
|
||||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration)node;
|
|
||||||
declSpec = (ICPPASTDeclSpecifier) decl.getDeclSpecifier();
|
|
||||||
}
|
|
||||||
if (declSpec.isFriend()) {
|
|
||||||
try {
|
try {
|
||||||
while (scope instanceof ICPPClassScope) {
|
while (scope instanceof ICPPClassScope) {
|
||||||
scope = scope.getParent();
|
scope = scope.getParent();
|
||||||
|
@ -252,6 +249,19 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ICPPASTDeclSpecifier getDeclSpecifier() {
|
||||||
|
if (definition != null) {
|
||||||
|
IASTNode node = ASTQueries.findOutermostDeclarator(definition).getParent();
|
||||||
|
IASTFunctionDefinition def = (IASTFunctionDefinition) node;
|
||||||
|
return (ICPPASTDeclSpecifier) def.getDeclSpecifier();
|
||||||
|
} else if (declarations != null && declarations.length != 0) {
|
||||||
|
IASTNode node = ASTQueries.findOutermostDeclarator(declarations[0]).getParent();
|
||||||
|
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) node;
|
||||||
|
return (ICPPASTDeclSpecifier) decl.getDeclSpecifier();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPFunctionType getType() {
|
public ICPPFunctionType getType() {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
|
@ -420,9 +430,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
||||||
|
|
||||||
IASTDeclSpecifier declSpec = null;
|
IASTDeclSpecifier declSpec = null;
|
||||||
if (parent instanceof IASTSimpleDeclaration) {
|
if (parent instanceof IASTSimpleDeclaration) {
|
||||||
declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier();
|
declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
|
||||||
} else if (parent instanceof IASTFunctionDefinition) {
|
} else if (parent instanceof IASTFunctionDefinition) {
|
||||||
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
|
declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier();
|
||||||
}
|
}
|
||||||
if (declSpec != null && declSpec.getStorageClass() == storage) {
|
if (declSpec != null && declSpec.getStorageClass() == storage) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -437,19 +447,14 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
static ICPPASTFunctionDefinition getFunctionDefinition(IASTNode def) {
|
||||||
public boolean isDeleted() {
|
|
||||||
return isDeletedDefinition(getDefinition());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isDeletedDefinition(IASTNode def) {
|
|
||||||
while (def != null && !(def instanceof IASTDeclaration)) {
|
while (def != null && !(def instanceof IASTDeclaration)) {
|
||||||
def= def.getParent();
|
def= def.getParent();
|
||||||
}
|
}
|
||||||
if (def instanceof ICPPASTFunctionDefinition) {
|
if (def instanceof ICPPASTFunctionDefinition) {
|
||||||
return ((ICPPASTFunctionDefinition) def).isDeleted();
|
return (ICPPASTFunctionDefinition) def;
|
||||||
}
|
}
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -511,6 +516,26 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
||||||
return hasStorageClass(this, IASTDeclSpecifier.sc_auto);
|
return hasStorageClass(this, IASTDeclSpecifier.sc_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConstexpr() {
|
||||||
|
ICPPASTDeclSpecifier declSpec = getDeclSpecifier();
|
||||||
|
if (declSpec == null)
|
||||||
|
return false;
|
||||||
|
return declSpec.isConstexpr();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDeleted() {
|
||||||
|
return isDeletedDefinition(getDefinition());
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isDeletedDefinition(IASTNode def) {
|
||||||
|
ICPPASTFunctionDefinition functionDefinition = getFunctionDefinition(def);
|
||||||
|
if (functionDefinition != null)
|
||||||
|
return functionDefinition.isDeleted();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return hasStorageClass(this, IASTDeclSpecifier.sc_register);
|
return hasStorageClass(this, IASTDeclSpecifier.sc_register);
|
||||||
|
@ -608,4 +633,46 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
||||||
ICPPASTFunctionDeclarator dtor = getPreferredDtor();
|
ICPPASTFunctionDeclarator dtor = getPreferredDtor();
|
||||||
return dtor != null && AttributeUtil.hasNoreturnAttribute(dtor);
|
return dtor != null && AttributeUtil.hasNoreturnAttribute(dtor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation getReturnExpression() {
|
||||||
|
if (!isConstexpr())
|
||||||
|
return null;
|
||||||
|
if (definition == null)
|
||||||
|
return EvalFixed.INCOMPLETE;
|
||||||
|
|
||||||
|
IASTNode node = ASTQueries.findOutermostDeclarator(definition).getParent();
|
||||||
|
return getReturnExpression((IASTFunctionDefinition) node);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ICPPEvaluation getReturnExpression(IASTFunctionDefinition functionDefinition) {
|
||||||
|
IASTReturnStatement returnStatement = null;
|
||||||
|
IASTStatement body = functionDefinition.getBody();
|
||||||
|
if (body instanceof IASTReturnStatement) {
|
||||||
|
returnStatement = (IASTReturnStatement) body;
|
||||||
|
} else if (body instanceof IASTCompoundStatement) {
|
||||||
|
for (IASTStatement statement : ((IASTCompoundStatement) body).getStatements()) {
|
||||||
|
if (statement instanceof IASTReturnStatement) {
|
||||||
|
if (returnStatement != null)
|
||||||
|
return EvalFixed.INCOMPLETE;
|
||||||
|
returnStatement = (IASTReturnStatement) statement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (returnStatement == null)
|
||||||
|
return EvalFixed.INCOMPLETE; // constexpr constructors are not supported yet.
|
||||||
|
|
||||||
|
IASTInitializerClause returnExpression = returnStatement.getReturnArgument();
|
||||||
|
if (returnExpression instanceof ICPPASTInitializerClause)
|
||||||
|
return ((ICPPASTInitializerClause) returnExpression).getEvaluation();
|
||||||
|
|
||||||
|
return EvalFixed.INCOMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICPPEvaluation getReturnExpression(ICPPFunction function) {
|
||||||
|
if (function instanceof ICPPComputableFunction) {
|
||||||
|
return ((ICPPComputableFunction) function).getReturnExpression();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
|
@ -43,7 +45,8 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
private ICPPParameter[] fParams;
|
private ICPPParameter[] fParams;
|
||||||
private final IType[] fExceptionSpecs;
|
private final IType[] fExceptionSpecs;
|
||||||
|
|
||||||
public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap, ICPPFunctionType type, IType[] exceptionSpecs) {
|
public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap,
|
||||||
|
ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||||
super(orig, owner, argMap);
|
super(orig, owner, argMap);
|
||||||
fType= type;
|
fType= type;
|
||||||
fExceptionSpecs= exceptionSpecs;
|
fExceptionSpecs= exceptionSpecs;
|
||||||
|
@ -103,19 +106,6 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDeleted() {
|
|
||||||
IASTNode def = getDefinition();
|
|
||||||
if (def != null)
|
|
||||||
return CPPFunction.isDeletedDefinition(def);
|
|
||||||
|
|
||||||
IBinding f = getSpecializedBinding();
|
|
||||||
if (f instanceof ICPPFunction) {
|
|
||||||
return ((ICPPFunction) f).isDeleted();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInline() {
|
public boolean isInline() {
|
||||||
if (getDefinition() != null) {
|
if (getDefinition() != null) {
|
||||||
|
@ -168,6 +158,33 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_auto);
|
return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConstexpr() {
|
||||||
|
IASTNode def = getDefinition();
|
||||||
|
if (def != null) {
|
||||||
|
ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(def);
|
||||||
|
return ((ICPPASTDeclSpecifier) functionDefinition.getDeclSpecifier()).isConstexpr();
|
||||||
|
}
|
||||||
|
IBinding f = getSpecializedBinding();
|
||||||
|
if (f instanceof ICPPFunction) {
|
||||||
|
return ((ICPPFunction) f).isConstexpr();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDeleted() {
|
||||||
|
IASTNode def = getDefinition();
|
||||||
|
if (def != null)
|
||||||
|
return CPPFunction.isDeletedDefinition(def);
|
||||||
|
|
||||||
|
IBinding f = getSpecializedBinding();
|
||||||
|
if (f instanceof ICPPFunction) {
|
||||||
|
return ((ICPPFunction) f).isDeleted();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
ICPPFunction f = (ICPPFunction) getSpecializedBinding();
|
ICPPFunction f = (ICPPFunction) getSpecializedBinding();
|
||||||
|
@ -314,4 +331,21 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
public IType[] getExceptionSpecification() {
|
public IType[] getExceptionSpecification() {
|
||||||
return fExceptionSpecs;
|
return fExceptionSpecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation getReturnExpression() {
|
||||||
|
if (!isConstexpr())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IASTNode def = getDefinition();
|
||||||
|
if (def != null) {
|
||||||
|
ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(def);
|
||||||
|
return CPPFunction.getReturnExpression(functionDefinition);
|
||||||
|
}
|
||||||
|
IBinding f = getSpecializedBinding();
|
||||||
|
if (f instanceof ICPPComputableFunction) {
|
||||||
|
return ((ICPPComputableFunction) f).getReturnExpression();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation 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
|
||||||
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
|
@ -41,6 +42,7 @@ 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.ASTQueries;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of function templates
|
* Implementation of function templates
|
||||||
|
@ -317,13 +319,21 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeleted() {
|
public boolean isAuto() {
|
||||||
return CPPFunction.isDeletedDefinition(getDefinition());
|
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuto() {
|
public boolean isConstexpr() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(getDefinition());
|
||||||
|
if (functionDefinition == null)
|
||||||
|
return false;
|
||||||
|
return ((ICPPASTDeclSpecifier) functionDefinition.getDeclSpecifier()).isConstexpr();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDeleted() {
|
||||||
|
return CPPFunction.isDeletedDefinition(getDefinition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -394,4 +404,14 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation getReturnExpression() {
|
||||||
|
if (!isConstexpr())
|
||||||
|
return null;
|
||||||
|
ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(getDefinition());
|
||||||
|
if (functionDefinition == null)
|
||||||
|
return EvalFixed.INCOMPLETE;
|
||||||
|
return CPPFunction.getReturnExpression(functionDefinition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,8 +255,8 @@ public abstract class CPPTemplateParameter extends PlatformObject
|
||||||
return current;
|
return current;
|
||||||
|
|
||||||
ICPPTemplateDefinition template= CPPTemplates.getContainingTemplate(getASTTemplateParameter());
|
ICPPTemplateDefinition template= CPPTemplates.getContainingTemplate(getASTTemplateParameter());
|
||||||
if (template instanceof ICPPInternalTemplate) {
|
if (template instanceof ICPPTemplateParameterOwner) {
|
||||||
return ((ICPPInternalTemplate) template).resolveTemplateParameter(this);
|
return ((ICPPTemplateParameterOwner) template).resolveTemplateParameter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// problem finding the containing template
|
// problem finding the containing template
|
||||||
|
|
|
@ -156,4 +156,9 @@ public class CPPUnknownMethod extends CPPUnknownMember implements ICPPMethod {
|
||||||
public boolean isFinal() {
|
public boolean isFinal() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConstexpr() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a function the return value of which may potentially be calculated at parsing time.
|
||||||
|
*/
|
||||||
|
public interface ICPPComputableFunction {
|
||||||
|
/**
|
||||||
|
* For a constexpr function returns the return statement expression. Otherwise returns
|
||||||
|
* {@code null}.
|
||||||
|
*/
|
||||||
|
public ICPPEvaluation getReturnExpression();
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionParameterMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assists in evaluating expressions.
|
* Assists in evaluating expressions.
|
||||||
|
@ -70,6 +72,17 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
||||||
ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||||
ICPPClassSpecialization within, int maxdepth, IASTNode point);
|
ICPPClassSpecialization within, int maxdepth, IASTNode point);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the evaluation produced by substituting function parameters by their values.
|
||||||
|
*
|
||||||
|
* @param parameterMap maps function parameters to their values
|
||||||
|
* @param maxdepth allowed recursion depth
|
||||||
|
* @param point determines the scope for name lookups
|
||||||
|
* @return the computed evaluation
|
||||||
|
*/
|
||||||
|
ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, int maxdepth,
|
||||||
|
IASTNode point);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines size of the template parameter pack.
|
* Determines size of the template parameter pack.
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
/**
|
/**
|
||||||
* Interface for ast-internal implementations of function bindings.
|
* Interface for ast-internal implementations of function bindings.
|
||||||
*/
|
*/
|
||||||
public interface ICPPInternalFunction extends ICPPInternalBinding {
|
public interface ICPPInternalFunction extends ICPPInternalBinding, ICPPComputableFunction {
|
||||||
/**
|
/**
|
||||||
* Called to resolve the parameter in the second phase.
|
* Called to resolve the parameter in the second phase.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation 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
|
||||||
|
@ -10,13 +10,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for templates from the ast.
|
* Interface for templates from the AST.
|
||||||
*/
|
*/
|
||||||
public interface ICPPInternalTemplate extends ICPPInternalBinding, ICPPInstanceCache {
|
public interface ICPPInternalTemplate
|
||||||
|
extends ICPPTemplateParameterOwner, ICPPInternalBinding, ICPPInstanceCache {
|
||||||
IBinding resolveTemplateParameter(ICPPTemplateParameter param);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for templates from the AST.
|
||||||
|
*/
|
||||||
|
public interface ICPPTemplateParameterOwner {
|
||||||
|
|
||||||
|
IBinding resolveTemplateParameter(ICPPTemplateParameter param);
|
||||||
|
}
|
|
@ -72,6 +72,11 @@ class AutoTypeResolver implements ICPPFunctionTemplate {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConstexpr() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IType[] getExceptionSpecification() {
|
public IType[] getExceptionSpecification() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps function parameter positions to values.
|
||||||
|
*/
|
||||||
|
public class CPPFunctionParameterMap {
|
||||||
|
public static final CPPFunctionParameterMap EMPTY = new CPPFunctionParameterMap(0);
|
||||||
|
|
||||||
|
private ObjectMap fMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an empty parameter map.
|
||||||
|
*/
|
||||||
|
public CPPFunctionParameterMap(int initialSize) {
|
||||||
|
fMap= new ObjectMap(initialSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CPPFunctionParameterMap(CPPFunctionParameterMap other) {
|
||||||
|
fMap= (ObjectMap) other.fMap.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the map contains the given parameter
|
||||||
|
*/
|
||||||
|
public boolean contains(int parameterPosition) {
|
||||||
|
return fMap.containsKey(parameterPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the mapping.
|
||||||
|
*/
|
||||||
|
public void put(int parameterPosition, ICPPEvaluation value) {
|
||||||
|
fMap.put(parameterPosition, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the mapping.
|
||||||
|
*/
|
||||||
|
public void put(int parameterPosition, ICPPEvaluation[] packExpansion) {
|
||||||
|
fMap.put(parameterPosition, packExpansion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value for the given parameter.
|
||||||
|
*/
|
||||||
|
public ICPPEvaluation getArgument(int parameterPosition) {
|
||||||
|
final Object object = fMap.get(parameterPosition);
|
||||||
|
if (object instanceof ICPPEvaluation) {
|
||||||
|
return (ICPPEvaluation) object;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the values for the given function parameter pack.
|
||||||
|
*/
|
||||||
|
public ICPPEvaluation[] getPackExpansion(int parameterPosition) {
|
||||||
|
final Object object = fMap.get(parameterPosition);
|
||||||
|
if (object instanceof ICPPEvaluation[]) {
|
||||||
|
return (ICPPEvaluation[]) object;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the argument at the given position
|
||||||
|
*/
|
||||||
|
public ICPPEvaluation getArgument(int parameterPosition, int packOffset) {
|
||||||
|
final Object object = fMap.get(parameterPosition);
|
||||||
|
if (object instanceof ICPPEvaluation)
|
||||||
|
return (ICPPEvaluation) object;
|
||||||
|
if (object instanceof ICPPEvaluation[]) {
|
||||||
|
ICPPEvaluation[] args = (ICPPEvaluation[]) object;
|
||||||
|
if (packOffset < args.length && packOffset >= 0)
|
||||||
|
return args[packOffset];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puts all mappings from the supplied map into this map.
|
||||||
|
*/
|
||||||
|
public void putAll(CPPFunctionParameterMap map) {
|
||||||
|
final ObjectMap otherMap= map.fMap;
|
||||||
|
for (int i = 0; i < otherMap.size(); i++) {
|
||||||
|
fMap.put(otherMap.keyAt(i), otherMap.getAt(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,6 +51,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
|
@ -558,6 +559,8 @@ public class CPPTemplates {
|
||||||
IASTDeclarator dtor = ((IASTFunctionDefinition) decl).getDeclarator();
|
IASTDeclarator dtor = ((IASTFunctionDefinition) decl).getDeclarator();
|
||||||
dtor= ASTQueries.findInnermostDeclarator(dtor);
|
dtor= ASTQueries.findInnermostDeclarator(dtor);
|
||||||
name = dtor.getName();
|
name = dtor.getName();
|
||||||
|
} else if (decl instanceof ICPPASTAliasDeclaration) {
|
||||||
|
name = ((ICPPASTAliasDeclaration) decl).getAlias();
|
||||||
}
|
}
|
||||||
if (name == null)
|
if (name == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -347,6 +347,16 @@ public class EvalBinary extends CPPEvaluation {
|
||||||
return new EvalBinary(fOperator, arg1, arg2);
|
return new EvalBinary(fOperator, arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
ICPPEvaluation arg1 = fArg1.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
ICPPEvaluation arg2 = fArg2.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (arg1 == fArg1 && arg2 == fArg2)
|
||||||
|
return this;
|
||||||
|
return new EvalBinary(fOperator, arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
return CPPTemplates.combinePackSize(fArg1.determinePackSize(tpMap), fArg2.determinePackSize(tpMap));
|
return CPPTemplates.combinePackSize(fArg1.determinePackSize(tpMap), fArg2.determinePackSize(tpMap));
|
||||||
|
|
|
@ -127,6 +127,12 @@ public class EvalBinaryTypeId extends CPPEvaluation {
|
||||||
return new EvalBinaryTypeId(fOperator, type1, type2);
|
return new EvalBinaryTypeId(fOperator, type1, type2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
return CPPTemplates.combinePackSize(CPPTemplates.determinePackSize(fType1, tpMap),
|
return CPPTemplates.combinePackSize(CPPTemplates.determinePackSize(fType1, tpMap),
|
||||||
|
|
|
@ -25,7 +25,9 @@ import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
|
@ -42,7 +44,22 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class EvalBinding extends CPPEvaluation {
|
public class EvalBinding extends CPPEvaluation {
|
||||||
private final IBinding fBinding;
|
/**
|
||||||
|
* The function owning the parameter if the binding is a function parameter, otherwise
|
||||||
|
* {@code null}. May be computed lazily and remains {@code null} until computed.
|
||||||
|
*/
|
||||||
|
private ICPPFunction fParameterOwner;
|
||||||
|
/**
|
||||||
|
* The position of the parameter in the parameter list if the binding is a function parameter,
|
||||||
|
* otherwise -1.
|
||||||
|
*/
|
||||||
|
private int fParameterPosition;
|
||||||
|
/**
|
||||||
|
* The binding represented by this evaluation. For a function parameter binding may be computed
|
||||||
|
* lazily to avoid infinite recursion during unmarshalling of the evaluation. If #fBinding is
|
||||||
|
* {@code null}, {@link #fParameterOwner} is guaranteed to be not {@code null} and vice versa.
|
||||||
|
*/
|
||||||
|
private IBinding fBinding;
|
||||||
private final boolean fFixedType;
|
private final boolean fFixedType;
|
||||||
|
|
||||||
private IType fType;
|
private IType fType;
|
||||||
|
@ -52,15 +69,79 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
private boolean fCheckedIsTypeDependent;
|
private boolean fCheckedIsTypeDependent;
|
||||||
|
|
||||||
public EvalBinding(IBinding binding, IType type) {
|
public EvalBinding(IBinding binding, IType type) {
|
||||||
|
fParameterPosition = -1;
|
||||||
fBinding= binding;
|
fBinding= binding;
|
||||||
fType= type;
|
fType= type;
|
||||||
fFixedType= type != null;
|
fFixedType= type != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EvalBinding(ICPPFunction parameterOwner, int parameterPosition, IType type) {
|
||||||
|
fParameterOwner = parameterOwner;
|
||||||
|
fParameterPosition = parameterPosition;
|
||||||
|
fType= type;
|
||||||
|
fFixedType= type != null;
|
||||||
|
}
|
||||||
|
|
||||||
public IBinding getBinding() {
|
public IBinding getBinding() {
|
||||||
|
if (fBinding == null) {
|
||||||
|
// fParameterOwner is guaranteed to be not null.
|
||||||
|
ICPPParameter[] parameters = fParameterOwner.getParameters();
|
||||||
|
fBinding = parameters[fParameterPosition];
|
||||||
|
}
|
||||||
return fBinding;
|
return fBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the binding is a function parameter, returns its position in the parameter list,
|
||||||
|
* otherwise returns -1
|
||||||
|
*/
|
||||||
|
public int getFunctionParameterPosition() {
|
||||||
|
if (fParameterPosition < 0) {
|
||||||
|
ICPPFunction parameterOwner = getParameterOwner();
|
||||||
|
if (parameterOwner != null) {
|
||||||
|
ICPPParameter[] parameters = fParameterOwner.getParameters();
|
||||||
|
fParameterPosition = findInArray(parameters, fBinding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fParameterPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the function owning the parameter if the binding is a function parameter,
|
||||||
|
* otherwise {@code null}.
|
||||||
|
*/
|
||||||
|
public ICPPFunction getParameterOwner() {
|
||||||
|
if (fParameterOwner == null && fBinding instanceof ICPPParameter) {
|
||||||
|
fParameterOwner = (ICPPFunction) ((ICPPParameter) fBinding).getOwner();
|
||||||
|
}
|
||||||
|
return fParameterOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a given object in an array.
|
||||||
|
*
|
||||||
|
* @param array the array to find the object in
|
||||||
|
* @param obj the object to find
|
||||||
|
* @return the index of the object in the array, or -1 if the object is not in the array
|
||||||
|
*/
|
||||||
|
private static int findInArray(Object[] array, Object obj) {
|
||||||
|
for (int i = 0; i < array.length; i++) {
|
||||||
|
if (obj == array[i])
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the binding is a template parameter, returns its ID, otherwise returns -1
|
||||||
|
*/
|
||||||
|
public int getTemplateParameterID() {
|
||||||
|
// No need to call getBinding method since fBinding cannot be null if the evaluation
|
||||||
|
// represents a template parameter.
|
||||||
|
return fBinding instanceof ICPPTemplateParameter ?
|
||||||
|
((ICPPTemplateParameter) fBinding).getParameterID() : -1;
|
||||||
|
}
|
||||||
|
|
||||||
public IType getFixedType() {
|
public IType getFixedType() {
|
||||||
return fFixedType ? fType : null;
|
return fFixedType ? fType : null;
|
||||||
}
|
}
|
||||||
|
@ -88,19 +169,22 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
IType t= null;
|
IType t= null;
|
||||||
if (fFixedType) {
|
if (fFixedType) {
|
||||||
t = fType;
|
t = fType;
|
||||||
} else if (fBinding instanceof IEnumerator) {
|
} else {
|
||||||
t= ((IEnumerator) fBinding).getType();
|
IBinding binding = getBinding();
|
||||||
} else if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
if (binding instanceof IEnumerator) {
|
||||||
t= ((ICPPTemplateNonTypeParameter) fBinding).getType();
|
t= ((IEnumerator) binding).getType();
|
||||||
} else if (fBinding instanceof IVariable) {
|
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||||
t = ((IVariable) fBinding).getType();
|
t= ((ICPPTemplateNonTypeParameter) binding).getType();
|
||||||
} else if (fBinding instanceof ICPPUnknownBinding) {
|
} else if (binding instanceof IVariable) {
|
||||||
|
t = ((IVariable) binding).getType();
|
||||||
|
} else if (binding instanceof ICPPUnknownBinding) {
|
||||||
return true;
|
return true;
|
||||||
} else if (fBinding instanceof IFunction) {
|
} else if (binding instanceof IFunction) {
|
||||||
t= ((IFunction) fBinding).getType();
|
t= ((IFunction) binding).getType();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return CPPTemplates.isDependentType(t);
|
return CPPTemplates.isDependentType(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +198,7 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean computeIsValueDependent() {
|
private boolean computeIsValueDependent() {
|
||||||
|
// No need to call getBinding() since a function parameter never has an initial value.
|
||||||
if (fBinding instanceof IEnumerator) {
|
if (fBinding instanceof IEnumerator) {
|
||||||
return Value.isDependentValue(((IEnumerator) fBinding).getValue());
|
return Value.isDependentValue(((IEnumerator) fBinding).getValue());
|
||||||
}
|
}
|
||||||
|
@ -141,23 +226,24 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IType computeType(IASTNode point) {
|
private IType computeType(IASTNode point) {
|
||||||
if (fBinding instanceof IEnumerator) {
|
IBinding binding = getBinding();
|
||||||
return ((IEnumerator) fBinding).getType();
|
if (binding instanceof IEnumerator) {
|
||||||
|
return ((IEnumerator) binding).getType();
|
||||||
}
|
}
|
||||||
if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||||
IType type= ((ICPPTemplateNonTypeParameter) fBinding).getType();
|
IType type= ((ICPPTemplateNonTypeParameter) binding).getType();
|
||||||
if (CPPTemplates.isDependentType(type))
|
if (CPPTemplates.isDependentType(type))
|
||||||
return new TypeOfDependentExpression(this);
|
return new TypeOfDependentExpression(this);
|
||||||
return prvalueType(type);
|
return prvalueType(type);
|
||||||
}
|
}
|
||||||
if (fBinding instanceof IVariable) {
|
if (binding instanceof IVariable) {
|
||||||
final IType type = ((IVariable) fBinding).getType();
|
final IType type = ((IVariable) binding).getType();
|
||||||
if (CPPTemplates.isDependentType(type))
|
if (CPPTemplates.isDependentType(type))
|
||||||
return new TypeOfDependentExpression(this);
|
return new TypeOfDependentExpression(this);
|
||||||
return SemanticUtil.mapToAST(glvalueType(type), point);
|
return SemanticUtil.mapToAST(glvalueType(type), point);
|
||||||
}
|
}
|
||||||
if (fBinding instanceof IFunction) {
|
if (binding instanceof IFunction) {
|
||||||
final IFunctionType type = ((IFunction) fBinding).getType();
|
final IFunctionType type = ((IFunction) binding).getType();
|
||||||
if (CPPTemplates.isDependentType(type))
|
if (CPPTemplates.isDependentType(type))
|
||||||
return new TypeOfDependentExpression(this);
|
return new TypeOfDependentExpression(this);
|
||||||
return SemanticUtil.mapToAST(type, point);
|
return SemanticUtil.mapToAST(type, point);
|
||||||
|
@ -171,6 +257,7 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
return Value.create(this);
|
return Value.create(this);
|
||||||
|
|
||||||
IValue value= null;
|
IValue value= null;
|
||||||
|
// No need to call getBinding() since a function parameter never has an initial value.
|
||||||
if (fBinding instanceof IInternalVariable) {
|
if (fBinding instanceof IInternalVariable) {
|
||||||
value= ((IInternalVariable) fBinding).getInitialValue(Value.MAX_RECURSION_DEPTH);
|
value= ((IInternalVariable) fBinding).getInitialValue(Value.MAX_RECURSION_DEPTH);
|
||||||
} else if (fBinding instanceof IVariable) {
|
} else if (fBinding instanceof IVariable) {
|
||||||
|
@ -189,7 +276,8 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
if (fBinding instanceof ICPPTemplateNonTypeParameter)
|
if (fBinding instanceof ICPPTemplateNonTypeParameter)
|
||||||
return ValueCategory.PRVALUE;
|
return ValueCategory.PRVALUE;
|
||||||
|
|
||||||
if (fBinding instanceof IVariable || fBinding instanceof IFunction) {
|
// fBinding can be null only when the evaluation represents a function parameter.
|
||||||
|
if (fBinding instanceof IFunction || fBinding instanceof IVariable || fBinding == null) {
|
||||||
return ValueCategory.LVALUE;
|
return ValueCategory.LVALUE;
|
||||||
}
|
}
|
||||||
return ValueCategory.PRVALUE;
|
return ValueCategory.PRVALUE;
|
||||||
|
@ -197,22 +285,39 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
|
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
|
||||||
buffer.putByte(ITypeMarshalBuffer.EVAL_BINDING);
|
byte firstByte = ITypeMarshalBuffer.EVAL_BINDING;
|
||||||
|
ICPPFunction parameterOwner = getParameterOwner();
|
||||||
|
if (parameterOwner != null) {
|
||||||
|
// A function parameter cannot be marshalled directly. We are storing the owning
|
||||||
|
// function and the parameter position instead.
|
||||||
|
buffer.putByte((byte) (ITypeMarshalBuffer.EVAL_BINDING | ITypeMarshalBuffer.FLAG1));
|
||||||
|
buffer.marshalBinding(parameterOwner);
|
||||||
|
buffer.putShort((short) getFunctionParameterPosition());
|
||||||
|
} else {
|
||||||
|
buffer.putByte(firstByte);
|
||||||
buffer.marshalBinding(fBinding);
|
buffer.marshalBinding(fBinding);
|
||||||
|
}
|
||||||
buffer.marshalType(fFixedType ? fType : null);
|
buffer.marshalType(fFixedType ? fType : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
|
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
|
||||||
|
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
|
||||||
|
ICPPFunction parameterOwner= (ICPPFunction) buffer.unmarshalBinding();
|
||||||
|
int parameterPosition= buffer.getShort();
|
||||||
|
IType type= buffer.unmarshalType();
|
||||||
|
return new EvalBinding(parameterOwner, parameterPosition, type);
|
||||||
|
} else {
|
||||||
IBinding binding= buffer.unmarshalBinding();
|
IBinding binding= buffer.unmarshalBinding();
|
||||||
IType type= buffer.unmarshalType();
|
IType type= buffer.unmarshalType();
|
||||||
return new EvalBinding(binding, type);
|
return new EvalBinding(binding, type);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||||
IBinding binding = fBinding;
|
IBinding binding = getBinding();
|
||||||
if (fBinding instanceof IEnumerator) {
|
if (binding instanceof IEnumerator) {
|
||||||
IEnumerator enumerator = (IEnumerator) binding;
|
IEnumerator enumerator = (IEnumerator) binding;
|
||||||
IType originalType = enumerator.getType();
|
IType originalType = enumerator.getType();
|
||||||
IType type = CPPTemplates.instantiateType(originalType, tpMap, packOffset, within, point);
|
IType type = CPPTemplates.instantiateType(originalType, tpMap, packOffset, within, point);
|
||||||
|
@ -221,23 +326,23 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
// TODO(sprigogin): Not sure if following condition is correct.
|
// TODO(sprigogin): Not sure if following condition is correct.
|
||||||
if (type != originalType || value != originalValue)
|
if (type != originalType || value != originalValue)
|
||||||
return new EvalFixed(type, ValueCategory.PRVALUE, value);
|
return new EvalFixed(type, ValueCategory.PRVALUE, value);
|
||||||
} else if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) fBinding);
|
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) binding);
|
||||||
if (argument != null && argument.isNonTypeValue()) {
|
if (argument != null && argument.isNonTypeValue()) {
|
||||||
return argument.getNonTypeEvaluation();
|
return argument.getNonTypeEvaluation();
|
||||||
}
|
}
|
||||||
// TODO(sprigogin): Do we need something similar for pack expansion?
|
// TODO(sprigogin): Do we need something similar for pack expansion?
|
||||||
} else if (fBinding instanceof ICPPUnknownBinding) {
|
} else if (binding instanceof ICPPUnknownBinding) {
|
||||||
binding = resolveUnknown((ICPPUnknownBinding) fBinding, tpMap, packOffset, within, point);
|
binding = resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point);
|
||||||
} else if (fBinding instanceof ICPPMethod) {
|
} else if (binding instanceof ICPPMethod) {
|
||||||
IBinding owner = fBinding.getOwner();
|
IBinding owner = binding.getOwner();
|
||||||
if (owner instanceof ICPPClassTemplate) {
|
if (owner instanceof ICPPClassTemplate) {
|
||||||
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner),
|
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner),
|
||||||
tpMap, packOffset, within, point);
|
tpMap, packOffset, within, point);
|
||||||
}
|
}
|
||||||
if (owner instanceof ICPPClassSpecialization) {
|
if (owner instanceof ICPPClassSpecialization) {
|
||||||
binding = CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
|
binding = CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
|
||||||
fBinding, point);
|
binding, point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (binding == fBinding)
|
if (binding == fBinding)
|
||||||
|
@ -246,20 +351,32 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
if (fBinding instanceof IEnumerator) {
|
int maxdepth, IASTNode point) {
|
||||||
return CPPTemplates.determinePackSize(((IEnumerator) fBinding).getValue(), tpMap);
|
int pos = getFunctionParameterPosition();
|
||||||
|
if (pos >= 0) {
|
||||||
|
ICPPEvaluation eval = parameterMap.getArgument(pos);
|
||||||
|
if (eval != null)
|
||||||
|
return eval;
|
||||||
}
|
}
|
||||||
if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
return this;
|
||||||
return CPPTemplates.determinePackSize((ICPPTemplateNonTypeParameter) fBinding, tpMap);
|
|
||||||
}
|
|
||||||
if (fBinding instanceof ICPPUnknownBinding) {
|
|
||||||
return CPPTemplates.determinePackSize((ICPPUnknownBinding) fBinding, tpMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IBinding binding = fBinding;
|
@Override
|
||||||
if (fBinding instanceof ICPPSpecialization) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
binding = ((ICPPSpecialization) fBinding).getSpecializedBinding();
|
IBinding binding = getBinding();
|
||||||
|
if (binding instanceof IEnumerator) {
|
||||||
|
return CPPTemplates.determinePackSize(((IEnumerator) binding).getValue(), tpMap);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||||
|
return CPPTemplates.determinePackSize((ICPPTemplateNonTypeParameter) binding, tpMap);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPUnknownBinding) {
|
||||||
|
return CPPTemplates.determinePackSize((ICPPUnknownBinding) binding, tpMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binding instanceof ICPPSpecialization) {
|
||||||
|
binding = ((ICPPSpecialization) binding).getSpecializedBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||||
|
@ -275,6 +392,8 @@ public class EvalBinding extends CPPEvaluation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean referencesTemplateParameter() {
|
public boolean referencesTemplateParameter() {
|
||||||
|
// No need to call getBinding method since fBinding cannot be null if the evaluation
|
||||||
|
// represents a template parameter.
|
||||||
return fBinding instanceof ICPPTemplateParameter;
|
return fBinding instanceof ICPPTemplateParameter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,25 @@ public class EvalComma extends CPPEvaluation {
|
||||||
return new EvalComma(args);
|
return new EvalComma(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
ICPPEvaluation[] args = fArguments;
|
||||||
|
for (int i = 0; i < fArguments.length; i++) {
|
||||||
|
ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (arg != fArguments[i]) {
|
||||||
|
if (args == fArguments) {
|
||||||
|
args = new ICPPEvaluation[fArguments.length];
|
||||||
|
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
|
||||||
|
}
|
||||||
|
args[i] = arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args == fArguments)
|
||||||
|
return this;
|
||||||
|
return new EvalComma(args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||||
|
|
|
@ -94,6 +94,15 @@ public class EvalCompound extends CPPEvaluation {
|
||||||
return new EvalCompound(delegate);
|
return new EvalCompound(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
ICPPEvaluation delegate = fDelegate.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (delegate == fDelegate)
|
||||||
|
return this;
|
||||||
|
return new EvalCompound(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
return fDelegate.determinePackSize(tpMap);
|
return fDelegate.determinePackSize(tpMap);
|
||||||
|
|
|
@ -336,6 +336,18 @@ public class EvalConditional extends CPPEvaluation {
|
||||||
return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows);
|
return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
ICPPEvaluation condition = fCondition.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
ICPPEvaluation positive = fPositive == null ?
|
||||||
|
null : fPositive.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
ICPPEvaluation negative = fNegative.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (condition == fCondition && positive == fPositive && negative == fNegative)
|
||||||
|
return this;
|
||||||
|
return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
int r = fCondition.determinePackSize(tpMap);
|
int r = fCondition.determinePackSize(tpMap);
|
||||||
|
|
|
@ -168,6 +168,18 @@ public class EvalFixed extends CPPEvaluation {
|
||||||
return new EvalFixed(type, fValueCategory, value);
|
return new EvalFixed(type, fValueCategory, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
ICPPEvaluation eval = fValue.getEvaluation();
|
||||||
|
if (eval == null)
|
||||||
|
return this;
|
||||||
|
eval = eval.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (eval == fValue.getEvaluation())
|
||||||
|
return this;
|
||||||
|
return new EvalFixed(fType, fValueCategory, Value.create(eval));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
return CPPTemplates.determinePackSize(fValue, tpMap);
|
return CPPTemplates.determinePackSize(fValue, tpMap);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType;
|
||||||
|
@ -22,6 +23,7 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
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.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -29,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
|
@ -139,8 +142,11 @@ public class EvalFunctionCall extends CPPEvaluation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IValue getValue(IASTNode point) {
|
public IValue getValue(IASTNode point) {
|
||||||
// TODO(sprigogin): Simulate execution of a function call if the value is not dependent.
|
ICPPEvaluation eval = computeForFunctionCall(Value.MAX_RECURSION_DEPTH, point);
|
||||||
return Value.create(this);
|
if (eval instanceof EvalFixed)
|
||||||
|
return ((EvalFixed) eval).getValue();
|
||||||
|
eval = new EvalFixed(getTypeOrFunctionSet(point), PRVALUE, eval.getValue(point));
|
||||||
|
return Value.create(eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -201,6 +207,70 @@ public class EvalFunctionCall extends CPPEvaluation {
|
||||||
return new EvalFunctionCall(args);
|
return new EvalFunctionCall(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
if (maxdepth == 0)
|
||||||
|
return EvalFixed.INCOMPLETE;
|
||||||
|
|
||||||
|
ICPPEvaluation[] args = fArguments;
|
||||||
|
for (int i = 0; i < fArguments.length; i++) {
|
||||||
|
ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (arg != fArguments[i]) {
|
||||||
|
if (args == fArguments) {
|
||||||
|
args = new ICPPEvaluation[fArguments.length];
|
||||||
|
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
|
||||||
|
}
|
||||||
|
args[i] = arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EvalFunctionCall eval = this;
|
||||||
|
if (args != fArguments)
|
||||||
|
eval = new EvalFunctionCall(args);
|
||||||
|
return eval.computeForFunctionCall(maxdepth - 1, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICPPEvaluation computeForFunctionCall(int maxdepth, IASTNode point) {
|
||||||
|
if (isValueDependent())
|
||||||
|
return this;
|
||||||
|
ICPPFunction function = getOverload(point);
|
||||||
|
if (function == null) {
|
||||||
|
if (fArguments[0] instanceof EvalBinding) {
|
||||||
|
IBinding binding = ((EvalBinding) fArguments[0]).getBinding();
|
||||||
|
if (binding instanceof ICPPFunction)
|
||||||
|
function = (ICPPFunction) binding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (function == null)
|
||||||
|
return this;
|
||||||
|
ICPPEvaluation eval = CPPFunction.getReturnExpression(function);
|
||||||
|
if (eval == null)
|
||||||
|
return EvalFixed.INCOMPLETE;
|
||||||
|
CPPFunctionParameterMap parameterMap = buildParameterMap(function);
|
||||||
|
return eval.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CPPFunctionParameterMap buildParameterMap(ICPPFunction function) {
|
||||||
|
ICPPParameter[] parameters = function.getParameters();
|
||||||
|
CPPFunctionParameterMap map = new CPPFunctionParameterMap(parameters.length);
|
||||||
|
int j = 1;
|
||||||
|
for (int i = 0; i < parameters.length; i++) {
|
||||||
|
ICPPParameter param = parameters[i];
|
||||||
|
if (param.isParameterPack()) {
|
||||||
|
// The parameter pack consumes all remaining arguments.
|
||||||
|
j = fArguments.length;
|
||||||
|
} else {
|
||||||
|
if (j < fArguments.length) {
|
||||||
|
map.put(i, fArguments[j++]);
|
||||||
|
} else if (param.hasDefaultValue()) {
|
||||||
|
IValue value = param.getInitialValue();
|
||||||
|
map.put(i, value.getEvaluation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||||
|
|
|
@ -170,6 +170,12 @@ public class EvalFunctionSet extends CPPEvaluation {
|
||||||
return new EvalFunctionSet(new CPPFunctionSet(functions, arguments, null), fAddressOf);
|
return new EvalFunctionSet(new CPPFunctionSet(functions, arguments, null), fAddressOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to resolve the function using the parameters of a function call.
|
* Attempts to resolve the function using the parameters of a function call.
|
||||||
*
|
*
|
||||||
|
|
|
@ -309,6 +309,17 @@ public class EvalID extends CPPEvaluation {
|
||||||
return new EvalID(fieldOwner, nameOwner, fName, fAddressOf, fQualified, templateArgs);
|
return new EvalID(fieldOwner, nameOwner, fName, fAddressOf, fQualified, templateArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
if (fFieldOwner == null)
|
||||||
|
return this;
|
||||||
|
ICPPEvaluation fieldOwner = fFieldOwner.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (fieldOwner == fFieldOwner)
|
||||||
|
return this;
|
||||||
|
return new EvalID(fieldOwner, fNameOwner, fName, fAddressOf, fQualified, fTemplateArgs);
|
||||||
|
}
|
||||||
|
|
||||||
private ICPPEvaluation resolveName(ICPPClassType nameOwner, ICPPTemplateArgument[] templateArgs,
|
private ICPPEvaluation resolveName(ICPPClassType nameOwner, ICPPTemplateArgument[] templateArgs,
|
||||||
IASTNode point) {
|
IASTNode point) {
|
||||||
LookupData data = new LookupData(fName, templateArgs, point);
|
LookupData data = new LookupData(fName, templateArgs, point);
|
||||||
|
|
|
@ -121,6 +121,25 @@ public class EvalInitList extends CPPEvaluation {
|
||||||
return new EvalInitList(clauses);
|
return new EvalInitList(clauses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
ICPPEvaluation[] clauses = fClauses;
|
||||||
|
for (int i = 0; i < fClauses.length; i++) {
|
||||||
|
ICPPEvaluation clause = fClauses[i].computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (clause != fClauses[i]) {
|
||||||
|
if (clauses == fClauses) {
|
||||||
|
clauses = new ICPPEvaluation[fClauses.length];
|
||||||
|
System.arraycopy(fClauses, 0, clauses, 0, fClauses.length);
|
||||||
|
}
|
||||||
|
clauses[i] = clause;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (clauses == fClauses)
|
||||||
|
return this;
|
||||||
|
return new EvalInitList(clauses);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||||
|
|
|
@ -334,6 +334,12 @@ public class EvalMemberAccess extends CPPEvaluation {
|
||||||
return new EvalMemberAccess(ownerType, fOwnerValueCategory, member, fIsPointerDeref);
|
return new EvalMemberAccess(ownerType, fOwnerValueCategory, member, fIsPointerDeref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
return CPPTemplates.determinePackSize(fOwnerType, tpMap);
|
return CPPTemplates.determinePackSize(fOwnerType, tpMap);
|
||||||
|
|
|
@ -165,6 +165,27 @@ public class EvalTypeId extends CPPEvaluation {
|
||||||
return new EvalTypeId(type, args);
|
return new EvalTypeId(type, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
ICPPEvaluation[] args = fArguments;
|
||||||
|
if (fArguments != null) {
|
||||||
|
for (int i = 0; i < fArguments.length; i++) {
|
||||||
|
ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (arg != fArguments[i]) {
|
||||||
|
if (args == fArguments) {
|
||||||
|
args = new ICPPEvaluation[fArguments.length];
|
||||||
|
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
|
||||||
|
}
|
||||||
|
args[i] = arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args == fArguments)
|
||||||
|
return this;
|
||||||
|
return new EvalTypeId(fInputType, args);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
int r = CPPTemplates.determinePackSize(fInputType, tpMap);
|
int r = CPPTemplates.determinePackSize(fInputType, tpMap);
|
||||||
|
|
|
@ -324,6 +324,16 @@ public class EvalUnary extends CPPEvaluation {
|
||||||
return new EvalUnary(fOperator, argument, aoqn);
|
return new EvalUnary(fOperator, argument, aoqn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
ICPPEvaluation argument = fArgument.computeForFunctionCall(parameterMap, maxdepth, point);
|
||||||
|
if (argument == fArgument)
|
||||||
|
return this;
|
||||||
|
|
||||||
|
return new EvalUnary(fOperator, argument, fAddressOfQualifiedNameBinding);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
return fArgument.determinePackSize(tpMap);
|
return fArgument.determinePackSize(tpMap);
|
||||||
|
|
|
@ -190,6 +190,12 @@ public class EvalUnaryTypeID extends CPPEvaluation {
|
||||||
return new EvalUnaryTypeID(fOperator, type);
|
return new EvalUnaryTypeID(fOperator, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||||
|
int maxdepth, IASTNode point) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
return CPPTemplates.determinePackSize(fOrigType, tpMap);
|
return CPPTemplates.determinePackSize(fOrigType, tpMap);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
@ -255,6 +256,16 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
||||||
}
|
}
|
||||||
if (eval instanceof EvalBinding) {
|
if (eval instanceof EvalBinding) {
|
||||||
EvalBinding e= (EvalBinding) eval;
|
EvalBinding e= (EvalBinding) eval;
|
||||||
|
ICPPFunction parameterOwner = e.getParameterOwner();
|
||||||
|
if (parameterOwner != null) {
|
||||||
|
IType b = e.getFixedType();
|
||||||
|
IBinding a2 = getCompositeBinding((IIndexFragmentBinding) parameterOwner);
|
||||||
|
IType b2 = getCompositeType(b);
|
||||||
|
if (parameterOwner != a2 || b != b2) {
|
||||||
|
int parameterPosition = e.getFunctionParameterPosition();
|
||||||
|
e= new EvalBinding((ICPPFunction) a2, parameterPosition, b2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
IBinding a = e.getBinding();
|
IBinding a = e.getBinding();
|
||||||
IType b = e.getFixedType();
|
IType b = e.getFixedType();
|
||||||
|
|
||||||
|
@ -262,6 +273,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
||||||
IType b2 = getCompositeType(b);
|
IType b2 = getCompositeType(b);
|
||||||
if (a != a2 || b != b2)
|
if (a != a2 || b != b2)
|
||||||
e= new EvalBinding(a2, b2);
|
e= new EvalBinding(a2, b2);
|
||||||
|
}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
if (eval instanceof EvalComma) {
|
if (eval instanceof EvalComma) {
|
||||||
|
|
|
@ -18,10 +18,13 @@ 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.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPComputableFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
|
||||||
class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
|
class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction, ICPPComputableFunction {
|
||||||
|
|
||||||
public CompositeCPPFunction(ICompositesFactory cf, ICPPFunction rbinding) {
|
public CompositeCPPFunction(ICompositesFactory cf, ICPPFunction rbinding) {
|
||||||
super(cf, rbinding);
|
super(cf, rbinding);
|
||||||
|
@ -42,6 +45,11 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
|
||||||
return ((ICPPFunction) rbinding).isMutable();
|
return ((ICPPFunction) rbinding).isMutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConstexpr() {
|
||||||
|
return ((ICPPFunction) rbinding).isConstexpr();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IScope getFunctionScope() {
|
public IScope getFunctionScope() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -129,4 +137,9 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation getReturnExpression() {
|
||||||
|
return CPPFunction.getReturnExpression((ICPPFunction) rbinding);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,10 +221,11 @@ public class PDOM extends PlatformObject implements IPDOM {
|
||||||
* 127.0 - Explicit virtual overrides, bug 380623.
|
* 127.0 - Explicit virtual overrides, bug 380623.
|
||||||
* 128.0 - Preservation of typedefs in template arguments.
|
* 128.0 - Preservation of typedefs in template arguments.
|
||||||
* 129.0 - Merged several changes affecting index from the master branch.
|
* 129.0 - Merged several changes affecting index from the master branch.
|
||||||
|
* 130.0 - Constexpr functions, bug 395238.
|
||||||
*/
|
*/
|
||||||
private static final int MIN_SUPPORTED_VERSION= version(129, 0);
|
private static final int MIN_SUPPORTED_VERSION= version(130, 0);
|
||||||
private static final int MAX_SUPPORTED_VERSION= version(129, Short.MAX_VALUE);
|
private static final int MAX_SUPPORTED_VERSION= version(130, Short.MAX_VALUE);
|
||||||
private static final int DEFAULT_VERSION = version(129, 0);
|
private static final int DEFAULT_VERSION = version(130, 0);
|
||||||
|
|
||||||
private static int version(int major, int minor) {
|
private static int version(int major, int minor) {
|
||||||
return (major << 16) + minor;
|
return (major << 16) + minor;
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class Database {
|
||||||
public static final int PTR_SIZE = 4; // size of a pointer in the database in bytes
|
public static final int PTR_SIZE = 4; // size of a pointer in the database in bytes
|
||||||
public static final int TYPE_SIZE = 2 + PTR_SIZE; // size of a type in the database in bytes
|
public static final int TYPE_SIZE = 2 + PTR_SIZE; // size of a type in the database in bytes
|
||||||
public static final int VALUE_SIZE = TYPE_SIZE; // size of a value in the database in bytes
|
public static final int VALUE_SIZE = TYPE_SIZE; // size of a value in the database in bytes
|
||||||
|
public static final int EVALUATION_SIZE = TYPE_SIZE; // size of an evaluation in the database in bytes
|
||||||
public static final int ARGUMENT_SIZE = TYPE_SIZE; // size of a template argument in the database in bytes
|
public static final int ARGUMENT_SIZE = TYPE_SIZE; // size of a template argument in the database in bytes
|
||||||
public static final long MAX_DB_SIZE= ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS));
|
public static final long MAX_DB_SIZE= ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS));
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
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.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +80,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
||||||
} else if (binding == null) {
|
} else if (binding == null) {
|
||||||
putByte(NULL_TYPE);
|
putByte(NULL_TYPE);
|
||||||
} else {
|
} else {
|
||||||
PDOMBinding pb= fLinkage.addTypeBinding(binding);
|
PDOMNode pb= fLinkage.addTypeBinding(binding);
|
||||||
if (pb == null) {
|
if (pb == null) {
|
||||||
putByte(UNSTORABLE_TYPE);
|
putByte(UNSTORABLE_TYPE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -423,7 +423,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract PDOMBinding addTypeBinding(IBinding type) throws CoreException;
|
public abstract PDOMBinding addTypeBinding(IBinding binding) throws CoreException;
|
||||||
public abstract IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException;
|
public abstract IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException;
|
||||||
public abstract IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException;
|
public abstract IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException;
|
||||||
public abstract ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer typeMarshalBuffer) throws CoreException;
|
public abstract ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer typeMarshalBuffer) throws CoreException;
|
||||||
|
@ -633,9 +633,41 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
}
|
}
|
||||||
|
|
||||||
public IValue loadValue(long offset) throws CoreException {
|
public IValue loadValue(long offset) throws CoreException {
|
||||||
|
TypeMarshalBuffer buffer = loadBuffer(offset, Database.VALUE_SIZE);
|
||||||
|
if (buffer == null)
|
||||||
|
return null;
|
||||||
|
return buffer.unmarshalValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void storeEvaluation(long offset, ISerializableEvaluation eval) throws CoreException {
|
||||||
|
final Database db= getDB();
|
||||||
|
deleteEvaluation(db, offset);
|
||||||
|
storeEvaluation(db, offset, eval);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storeEvaluation(Database db, long offset, ISerializableEvaluation eval) throws CoreException {
|
||||||
|
if (eval != null) {
|
||||||
|
TypeMarshalBuffer bc= new TypeMarshalBuffer(this);
|
||||||
|
bc.marshalEvaluation(eval, true);
|
||||||
|
storeBuffer(db, offset, bc, Database.EVALUATION_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteEvaluation(Database db, long offset) throws CoreException {
|
||||||
|
deleteSerializedData(db, offset, Database.EVALUATION_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISerializableEvaluation loadEvaluation(long offset) throws CoreException {
|
||||||
|
TypeMarshalBuffer buffer = loadBuffer(offset, Database.EVALUATION_SIZE);
|
||||||
|
if (buffer == null)
|
||||||
|
return null;
|
||||||
|
return buffer.unmarshalEvaluation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TypeMarshalBuffer loadBuffer(long offset, int size) throws CoreException {
|
||||||
final Database db= getDB();
|
final Database db= getDB();
|
||||||
final byte firstByte= db.getByte(offset);
|
final byte firstByte= db.getByte(offset);
|
||||||
byte[] data= null;
|
byte[] data;
|
||||||
switch (firstByte) {
|
switch (firstByte) {
|
||||||
case TypeMarshalBuffer.INDIRECT_TYPE:
|
case TypeMarshalBuffer.INDIRECT_TYPE:
|
||||||
data = loadLinkedSerializedData(db, offset + 1);
|
data = loadLinkedSerializedData(db, offset + 1);
|
||||||
|
@ -643,11 +675,11 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
case TypeMarshalBuffer.NULL_TYPE:
|
case TypeMarshalBuffer.NULL_TYPE:
|
||||||
return null;
|
return null;
|
||||||
default:
|
default:
|
||||||
data= new byte[Database.VALUE_SIZE];
|
data= new byte[size];
|
||||||
db.getBytes(offset, data);
|
db.getBytes(offset, data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return new TypeMarshalBuffer(this, data).unmarshalValue();
|
return new TypeMarshalBuffer(this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexScope[] getInlineNamespaces() {
|
public IIndexScope[] getInlineNamespaces() {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Thomas Corbat (IFS) - Initial API and implementation
|
* Thomas Corbat (IFS) - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -15,7 +16,10 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||||
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.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
|
@ -24,39 +28,38 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
/**
|
/**
|
||||||
* PDOM binding for alias template.
|
* PDOM binding for alias template.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate {
|
class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate, IPDOMCPPTemplateParameterOwner {
|
||||||
private static final int ALIASED_TYPE_SIZE = Database.TYPE_SIZE;
|
private static final int ALIASED_TYPE_SIZE = Database.TYPE_SIZE;
|
||||||
private static final int TEMPLATE_PARAMS_SIZE = PDOMCPPTemplateTemplateParameter.RECORD_SIZE;
|
private static final int TEMPLATE_PARAMS_SIZE = PDOMCPPTemplateTemplateParameter.RECORD_SIZE;
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + ALIASED_TYPE_SIZE + TEMPLATE_PARAMS_SIZE;
|
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + ALIASED_TYPE_SIZE + TEMPLATE_PARAMS_SIZE;
|
||||||
|
|
||||||
private static final int ALIASED_TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE + 0;
|
private static final int ALIASED_TYPE = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||||
private static final int TEMPLATE_PARAMS_OFFSET = ALIASED_TYPE_OFFSET + ALIASED_TYPE_SIZE;
|
private static final int TEMPLATE_PARAMS = ALIASED_TYPE + ALIASED_TYPE_SIZE;
|
||||||
|
|
||||||
private volatile IPDOMCPPTemplateParameter[] parameters;
|
private volatile IPDOMCPPTemplateParameter[] parameters;
|
||||||
|
|
||||||
public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, PDOMNode parent,
|
public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPAliasTemplate template)
|
||||||
ICPPAliasTemplate templateAlias) throws CoreException, DOMException {
|
throws CoreException, DOMException {
|
||||||
super(linkage, parent, templateAlias.getNameCharArray());
|
super(linkage, parent, template.getNameCharArray());
|
||||||
setTemplateParameters(linkage, templateAlias.getTemplateParameters());
|
final ICPPTemplateParameter[] origParams= template.getTemplateParameters();
|
||||||
setType(linkage, templateAlias.getType());
|
parameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
|
||||||
|
final Database db = getDB();
|
||||||
|
long rec= PDOMTemplateParameterArray.putArray(db, parameters);
|
||||||
|
db.putRecPtr(record + TEMPLATE_PARAMS, rec);
|
||||||
|
linkage.new ConfigureAliasTemplate(template, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, long record) {
|
public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, long record) {
|
||||||
super(linkage, record);
|
super(linkage, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTemplateParameters(PDOMCPPLinkage linkage,
|
public void initData(IType aliasedType) {
|
||||||
final ICPPTemplateParameter[] origParams) throws CoreException, DOMException {
|
try {
|
||||||
parameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
|
getLinkage().storeType(record + ALIASED_TYPE, aliasedType);
|
||||||
final Database db = getDB();
|
} catch (CoreException e) {
|
||||||
long rec= PDOMTemplateParameterArray.putArray(db, parameters);
|
CCorePlugin.log(e);
|
||||||
db.putRecPtr(record + TEMPLATE_PARAMS_OFFSET, rec);
|
|
||||||
linkage.new ConfigureTemplateParameters(origParams, parameters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setType(PDOMCPPLinkage linkage, IType aliasedType) throws CoreException {
|
|
||||||
linkage.storeType(record + ALIASED_TYPE_OFFSET, aliasedType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,11 +77,11 @@ class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPTemplateParameter[] getTemplateParameters() {
|
public IPDOMCPPTemplateParameter[] getTemplateParameters() {
|
||||||
if (parameters == null) {
|
if (parameters == null) {
|
||||||
try {
|
try {
|
||||||
Database db = getDB();
|
Database db = getDB();
|
||||||
long rec= db.getRecPtr(record + TEMPLATE_PARAMS_OFFSET);
|
long rec= db.getRecPtr(record + TEMPLATE_PARAMS);
|
||||||
if (rec == 0) {
|
if (rec == 0) {
|
||||||
parameters= IPDOMCPPTemplateParameter.EMPTY_ARRAY;
|
parameters= IPDOMCPPTemplateParameter.EMPTY_ARRAY;
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,7 +98,7 @@ class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate {
|
||||||
@Override
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
try {
|
try {
|
||||||
return getLinkage().loadType(record + ALIASED_TYPE_OFFSET);
|
return getLinkage().loadType(record + ALIASED_TYPE);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return null;
|
return null;
|
||||||
|
@ -115,4 +118,27 @@ class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param) {
|
||||||
|
// Template parameters are identified by their position in the parameter list.
|
||||||
|
int pos = param.getParameterPosition();
|
||||||
|
ICPPTemplateParameter[] pars = getTemplateParameters();
|
||||||
|
|
||||||
|
if (pars == null || pos >= pars.length)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ICPPTemplateParameter result= pars[pos];
|
||||||
|
if (param instanceof ICPPTemplateTypeParameter) {
|
||||||
|
if (result instanceof ICPPTemplateTypeParameter)
|
||||||
|
return result;
|
||||||
|
} else if (param instanceof ICPPTemplateNonTypeParameter) {
|
||||||
|
if (result instanceof ICPPTemplateNonTypeParameter)
|
||||||
|
return result;
|
||||||
|
} else if (param instanceof ICPPTemplateTemplateParameter) {
|
||||||
|
if (result instanceof ICPPTemplateTemplateParameter)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor {
|
class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor {
|
||||||
|
|
||||||
public PDOMCPPConstructor(PDOMLinkage linkage, PDOMNode parent, ICPPConstructor method)
|
public PDOMCPPConstructor(PDOMCPPLinkage linkage, PDOMNode parent, ICPPConstructor method)
|
||||||
throws CoreException, DOMException {
|
throws CoreException, DOMException {
|
||||||
super(linkage, parent, method);
|
super(linkage, parent, method);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPComputableFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
|
@ -37,9 +40,10 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
/**
|
/**
|
||||||
* Binding for c++ functions in the index.
|
* Binding for c++ functions in the index.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverloader {
|
class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverloader, ICPPComputableFunction {
|
||||||
private static final short ANNOT_PARAMETER_PACK = 8;
|
private static final short ANNOT_PARAMETER_PACK = 8;
|
||||||
private static final short ANNOT_IS_DELETED = 9;
|
private static final short ANNOT_IS_DELETED = 9;
|
||||||
|
private static final short ANNOT_IS_CONSTEXPR = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset of total number of function parameters (relative to the beginning of the record).
|
* Offset of total number of function parameters (relative to the beginning of the record).
|
||||||
|
@ -72,28 +76,31 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
*/
|
*/
|
||||||
private static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short
|
private static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short
|
||||||
|
|
||||||
private static final int REQUIRED_ARG_COUNT = ANNOTATION + 2;
|
/** Offset of the number of the required arguments. */
|
||||||
|
private static final int REQUIRED_ARG_COUNT = ANNOTATION + 2; // short
|
||||||
|
|
||||||
|
/** Offset of the return expression for constexpr functions. */
|
||||||
|
private static final int RETURN_EXPRESSION = REQUIRED_ARG_COUNT + 2; // Database.EVALUATION_SIZE
|
||||||
/**
|
/**
|
||||||
* The size in bytes of a PDOMCPPFunction record in the database.
|
* The size in bytes of a PDOMCPPFunction record in the database.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT + 4;
|
protected static final int RECORD_SIZE = RETURN_EXPRESSION + Database.EVALUATION_SIZE;
|
||||||
|
|
||||||
private short fAnnotation = -1;
|
private short fAnnotation = -1;
|
||||||
private int fRequiredArgCount = -1;
|
private int fRequiredArgCount = -1;
|
||||||
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
|
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
|
||||||
|
|
||||||
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function,
|
public PDOMCPPFunction(PDOMCPPLinkage linkage, PDOMNode parent, ICPPFunction function,
|
||||||
boolean setTypes) throws CoreException, DOMException {
|
boolean setTypes) throws CoreException, DOMException {
|
||||||
super(linkage, parent, function.getNameCharArray());
|
super(linkage, parent, function.getNameCharArray());
|
||||||
Database db = getDB();
|
Database db = getDB();
|
||||||
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
|
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
|
||||||
getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
|
getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
|
||||||
db.putShort(record + ANNOTATION, getAnnotation(function));
|
db.putShort(record + ANNOTATION, getAnnotation(function));
|
||||||
db.putInt(record + REQUIRED_ARG_COUNT, function.getRequiredArgumentCount());
|
db.putShort(record + REQUIRED_ARG_COUNT, (short) function.getRequiredArgumentCount());
|
||||||
if (setTypes) {
|
if (setTypes) {
|
||||||
initData(function.getType(), function.getParameters(), extractExceptionSpec(function));
|
linkage.new ConfigureFunction(function, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,14 +112,19 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
if (function.isDeleted()) {
|
if (function.isDeleted()) {
|
||||||
annot |= (1 << ANNOT_IS_DELETED);
|
annot |= (1 << ANNOT_IS_DELETED);
|
||||||
}
|
}
|
||||||
|
if (function.isConstexpr()) {
|
||||||
|
annot |= (1 << ANNOT_IS_CONSTEXPR);
|
||||||
|
}
|
||||||
return (short) annot;
|
return (short) annot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initData(ICPPFunctionType ftype, ICPPParameter[] params, IType[] exceptionSpec) {
|
public void initData(ICPPFunctionType ftype, ICPPParameter[] params, IType[] exceptionSpec,
|
||||||
|
ICPPEvaluation returnExpression) {
|
||||||
try {
|
try {
|
||||||
setType(ftype);
|
setType(ftype);
|
||||||
setParameters(params);
|
setParameters(params);
|
||||||
storeExceptionSpec(exceptionSpec);
|
storeExceptionSpec(exceptionSpec);
|
||||||
|
getLinkage().storeEvaluation(record + RETURN_EXPRESSION, returnExpression);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +132,9 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||||
if (newBinding instanceof ICPPFunction) {
|
if (!(newBinding instanceof ICPPFunction))
|
||||||
|
return;
|
||||||
|
|
||||||
ICPPFunction func = (ICPPFunction) newBinding;
|
ICPPFunction func = (ICPPFunction) newBinding;
|
||||||
ICPPFunctionType newType;
|
ICPPFunctionType newType;
|
||||||
ICPPParameter[] newParams;
|
ICPPParameter[] newParams;
|
||||||
|
@ -162,7 +176,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
final Database db = getDB();
|
final Database db = getDB();
|
||||||
db.putShort(record + ANNOTATION, newAnnotation);
|
db.putShort(record + ANNOTATION, newAnnotation);
|
||||||
fAnnotation = newAnnotation;
|
fAnnotation = newAnnotation;
|
||||||
db.putInt(record + REQUIRED_ARG_COUNT, requiredCount);
|
db.putShort(record + REQUIRED_ARG_COUNT, (short) requiredCount);
|
||||||
fRequiredArgCount = requiredCount;
|
fRequiredArgCount = requiredCount;
|
||||||
|
|
||||||
long oldRec = db.getRecPtr(record + EXCEPTION_SPEC);
|
long oldRec = db.getRecPtr(record + EXCEPTION_SPEC);
|
||||||
|
@ -170,7 +184,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
if (oldRec != 0) {
|
if (oldRec != 0) {
|
||||||
PDOMCPPTypeList.clearTypes(this, oldRec);
|
PDOMCPPTypeList.clearTypes(this, oldRec);
|
||||||
}
|
}
|
||||||
}
|
linkage.storeEvaluation(record + RETURN_EXPRESSION, CPPFunction.getReturnExpression(func));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeExceptionSpec(IType[] exceptionSpec) throws CoreException {
|
private void storeExceptionSpec(IType[] exceptionSpec) throws CoreException {
|
||||||
|
@ -243,7 +257,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
public int getRequiredArgumentCount() {
|
public int getRequiredArgumentCount() {
|
||||||
if (fRequiredArgCount == -1) {
|
if (fRequiredArgCount == -1) {
|
||||||
try {
|
try {
|
||||||
fRequiredArgCount = getDB().getInt(record + REQUIRED_ARG_COUNT);
|
fRequiredArgCount = getDB().getShort(record + REQUIRED_ARG_COUNT);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
fRequiredArgCount = 0;
|
fRequiredArgCount = 0;
|
||||||
}
|
}
|
||||||
|
@ -321,6 +335,11 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConstexpr() {
|
||||||
|
return getBit(getAnnotation(), ANNOT_IS_CONSTEXPR);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
return getBit(getAnnotation(), ANNOT_IS_DELETED);
|
return getBit(getAnnotation(), ANNOT_IS_DELETED);
|
||||||
|
@ -394,4 +413,17 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation getReturnExpression() {
|
||||||
|
if (!isConstexpr())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return (ICPPEvaluation) getLinkage().loadEvaluation(record + RETURN_EXPRESSION);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPComputableFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
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.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
|
@ -34,7 +37,8 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
/**
|
/**
|
||||||
* Binding for function specialization in the index.
|
* Binding for function specialization in the index.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICPPFunction {
|
class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization
|
||||||
|
implements ICPPFunction, ICPPComputableFunction {
|
||||||
/**
|
/**
|
||||||
* Offset of total number of function parameters (relative to the beginning of the record).
|
* Offset of total number of function parameters (relative to the beginning of the record).
|
||||||
*/
|
*/
|
||||||
|
@ -59,24 +63,29 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
/**
|
/**
|
||||||
* Offset of annotation information (relative to the beginning of the record).
|
* Offset of annotation information (relative to the beginning of the record).
|
||||||
*/
|
*/
|
||||||
protected static final int ANNOTATION_OFFSET = EXCEPTION_SPEC + Database.PTR_SIZE; // short
|
protected static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short
|
||||||
|
|
||||||
private static final int REQUIRED_ARG_COUNT_OFFSET= ANNOTATION_OFFSET + 2;
|
/** Offset of the number of the required arguments. */
|
||||||
|
private static final int REQUIRED_ARG_COUNT = ANNOTATION + 2; // short
|
||||||
|
|
||||||
|
/** Offset of the return expression for constexpr functions. */
|
||||||
|
private static final int RETURN_EXPRESSION = REQUIRED_ARG_COUNT + 2; // Database.EVALUATION_SIZE
|
||||||
/**
|
/**
|
||||||
* The size in bytes of a PDOMCPPFunction record in the database.
|
* The size in bytes of a PDOMCPPFunctionSpecialization record in the database.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT_OFFSET + 4;
|
protected static final int RECORD_SIZE = RETURN_EXPRESSION + Database.EVALUATION_SIZE;
|
||||||
|
|
||||||
private static final short ANNOT_PARAMETER_PACK = 8;
|
private static final short ANNOT_PARAMETER_PACK = 8;
|
||||||
private static final short ANNOT_IS_DELETED = 9;
|
private static final short ANNOT_IS_DELETED = 9;
|
||||||
|
private static final short ANNOT_IS_CONSTEXPR = 10;
|
||||||
|
|
||||||
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
|
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
|
||||||
private short fAnnotation= -1;
|
private short fAnnotation= -1;
|
||||||
private int fRequiredArgCount= -1;
|
private int fRequiredArgCount= -1;
|
||||||
|
|
||||||
public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPFunction astFunction, PDOMBinding specialized) throws CoreException {
|
public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPFunction astFunction,
|
||||||
|
PDOMBinding specialized) throws CoreException {
|
||||||
super(linkage, parent, (ICPPSpecialization) astFunction, specialized);
|
super(linkage, parent, (ICPPSpecialization) astFunction, specialized);
|
||||||
|
|
||||||
Database db = getDB();
|
Database db = getDB();
|
||||||
|
@ -112,8 +121,12 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
|
db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
|
||||||
}
|
}
|
||||||
fAnnotation = getAnnotation(astFunction);
|
fAnnotation = getAnnotation(astFunction);
|
||||||
db.putShort(record + ANNOTATION_OFFSET, fAnnotation);
|
db.putShort(record + ANNOTATION, fAnnotation);
|
||||||
db.putInt(record + REQUIRED_ARG_COUNT_OFFSET, astFunction.getRequiredArgumentCount());
|
db.putShort(record + REQUIRED_ARG_COUNT , (short) astFunction.getRequiredArgumentCount());
|
||||||
|
ICPPEvaluation returnExpression = CPPFunction.getReturnExpression(astFunction);
|
||||||
|
if (returnExpression != null) {
|
||||||
|
linkage.storeEvaluation(record + RETURN_EXPRESSION, returnExpression);
|
||||||
|
}
|
||||||
long typelist= 0;
|
long typelist= 0;
|
||||||
if (astFunction instanceof ICPPMethod && ((ICPPMethod) astFunction).isImplicit()) {
|
if (astFunction instanceof ICPPMethod && ((ICPPMethod) astFunction).isImplicit()) {
|
||||||
// Don't store the exception specification, it is computed on demand.
|
// Don't store the exception specification, it is computed on demand.
|
||||||
|
@ -131,6 +144,9 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
if (astFunction.isDeleted()) {
|
if (astFunction.isDeleted()) {
|
||||||
annot |= (1 << ANNOT_IS_DELETED);
|
annot |= (1 << ANNOT_IS_DELETED);
|
||||||
}
|
}
|
||||||
|
if (astFunction.isConstexpr()) {
|
||||||
|
annot |= (1 << ANNOT_IS_CONSTEXPR);
|
||||||
|
}
|
||||||
return (short) annot;
|
return (short) annot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +172,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
private short readAnnotation() {
|
private short readAnnotation() {
|
||||||
if (fAnnotation == -1) {
|
if (fAnnotation == -1) {
|
||||||
try {
|
try {
|
||||||
fAnnotation= getDB().getShort(record + ANNOTATION_OFFSET);
|
fAnnotation= getDB().getShort(record + ANNOTATION);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
fAnnotation= 0;
|
fAnnotation= 0;
|
||||||
}
|
}
|
||||||
|
@ -219,6 +235,11 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConstexpr() {
|
||||||
|
return getBit(readAnnotation(), ANNOT_IS_CONSTEXPR);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return getBit(readAnnotation(), PDOMCAnnotation.EXTERN_OFFSET);
|
return getBit(readAnnotation(), PDOMCAnnotation.EXTERN_OFFSET);
|
||||||
|
@ -254,7 +275,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
public int getRequiredArgumentCount() {
|
public int getRequiredArgumentCount() {
|
||||||
if (fRequiredArgCount == -1) {
|
if (fRequiredArgCount == -1) {
|
||||||
try {
|
try {
|
||||||
fRequiredArgCount= getDB().getInt(record + REQUIRED_ARG_COUNT_OFFSET);
|
fRequiredArgCount= getDB().getShort(record + REQUIRED_ARG_COUNT );
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
fRequiredArgCount= 0;
|
fRequiredArgCount= 0;
|
||||||
}
|
}
|
||||||
|
@ -300,4 +321,17 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPEvaluation getReturnExpression() {
|
||||||
|
if (!isConstexpr())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return (ICPPEvaluation) getLinkage().loadEvaluation(record + RETURN_EXPRESSION);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
|
@ -61,8 +63,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
|
@ -79,21 +79,23 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplateInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClosureType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClosureType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplateInstance;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMember;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMember;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary;
|
||||||
|
@ -219,6 +221,29 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ConfigureFunction implements Runnable {
|
||||||
|
private final PDOMCPPFunction fFunction;
|
||||||
|
private final ICPPFunctionType fOriginalFunctionType;
|
||||||
|
private final ICPPParameter[] fOriginalParameters;
|
||||||
|
private final IType[] fOriginalExceptionSpec;
|
||||||
|
private final ICPPEvaluation fReturnExpression;
|
||||||
|
|
||||||
|
public ConfigureFunction(ICPPFunction original, PDOMCPPFunction function) throws DOMException {
|
||||||
|
fFunction = function;
|
||||||
|
fOriginalFunctionType= original.getType();
|
||||||
|
fOriginalParameters= original.getParameters();
|
||||||
|
fOriginalExceptionSpec= function.extractExceptionSpec(original);
|
||||||
|
fReturnExpression= CPPFunction.getReturnExpression(original);
|
||||||
|
postProcesses.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fFunction.initData(fOriginalFunctionType, fOriginalParameters, fOriginalExceptionSpec,
|
||||||
|
fReturnExpression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigureFunctionTemplate implements Runnable {
|
class ConfigureFunctionTemplate implements Runnable {
|
||||||
private final PDOMCPPFunctionTemplate fTemplate;
|
private final PDOMCPPFunctionTemplate fTemplate;
|
||||||
private final IPDOMCPPTemplateParameter[] fTemplateParameters;
|
private final IPDOMCPPTemplateParameter[] fTemplateParameters;
|
||||||
|
@ -226,6 +251,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
private final ICPPFunctionType fOriginalFunctionType;
|
private final ICPPFunctionType fOriginalFunctionType;
|
||||||
private final ICPPParameter[] fOriginalParameters;
|
private final ICPPParameter[] fOriginalParameters;
|
||||||
private final IType[] fOriginalExceptionSpec;
|
private final IType[] fOriginalExceptionSpec;
|
||||||
|
private final ICPPEvaluation fReturnExpression;
|
||||||
|
|
||||||
public ConfigureFunctionTemplate(ICPPFunctionTemplate original, PDOMCPPFunctionTemplate template) throws DOMException {
|
public ConfigureFunctionTemplate(ICPPFunctionTemplate original, PDOMCPPFunctionTemplate template) throws DOMException {
|
||||||
fTemplate = template;
|
fTemplate = template;
|
||||||
|
@ -234,6 +260,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
fOriginalFunctionType= original.getType();
|
fOriginalFunctionType= original.getType();
|
||||||
fOriginalParameters= original.getParameters();
|
fOriginalParameters= original.getParameters();
|
||||||
fOriginalExceptionSpec= template.extractExceptionSpec(original);
|
fOriginalExceptionSpec= template.extractExceptionSpec(original);
|
||||||
|
fReturnExpression= CPPFunction.getReturnExpression(original);
|
||||||
postProcesses.add(this);
|
postProcesses.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +271,33 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
if (tp != null)
|
if (tp != null)
|
||||||
tp.configure(fOriginalTemplateParameters[i]);
|
tp.configure(fOriginalTemplateParameters[i]);
|
||||||
}
|
}
|
||||||
fTemplate.initData(fOriginalFunctionType, fOriginalParameters, fOriginalExceptionSpec);
|
fTemplate.initData(fOriginalFunctionType, fOriginalParameters, fOriginalExceptionSpec,
|
||||||
|
fReturnExpression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConfigureAliasTemplate implements Runnable {
|
||||||
|
private final PDOMCPPAliasTemplate fTemplate;
|
||||||
|
private final IPDOMCPPTemplateParameter[] fTemplateParameters;
|
||||||
|
private final ICPPTemplateParameter[] fOriginalTemplateParameters;
|
||||||
|
private final IType fOriginalAliasedType;
|
||||||
|
|
||||||
|
public ConfigureAliasTemplate(ICPPAliasTemplate original, PDOMCPPAliasTemplate template) throws DOMException {
|
||||||
|
fTemplate = template;
|
||||||
|
fTemplateParameters= template.getTemplateParameters();
|
||||||
|
fOriginalTemplateParameters= original.getTemplateParameters();
|
||||||
|
fOriginalAliasedType= original.getType();
|
||||||
|
postProcesses.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (int i = 0; i < fOriginalTemplateParameters.length; i++) {
|
||||||
|
final IPDOMCPPTemplateParameter tp = fTemplateParameters[i];
|
||||||
|
if (tp != null)
|
||||||
|
tp.configure(fOriginalTemplateParameters[i]);
|
||||||
|
}
|
||||||
|
fTemplate.initData(fOriginalAliasedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +323,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds or returns existing binding for the given one. If <code>fromName</code> is not <code>null</code>
|
* Adds or returns existing binding for the given one. If {@code fromName} is not {@code null},
|
||||||
* then an existing binding is updated with the properties of the name.
|
* then an existing binding is updated with the properties of the name.
|
||||||
*/
|
*/
|
||||||
private PDOMBinding addBinding(IBinding inputBinding, IASTName fromName) throws CoreException {
|
private PDOMBinding addBinding(IBinding inputBinding, IASTName fromName) throws CoreException {
|
||||||
|
@ -624,8 +677,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
return adaptBinding(null, inputBinding, includeLocal ? FILE_LOCAL_REC_DUMMY : null);
|
return adaptBinding(null, inputBinding, includeLocal ? FILE_LOCAL_REC_DUMMY : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, long[] fileLocalRecHolder)
|
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding,
|
||||||
throws CoreException {
|
long[] fileLocalRecHolder) throws CoreException {
|
||||||
if (cannotAdapt(inputBinding)) {
|
if (cannotAdapt(inputBinding)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -635,7 +688,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign names to anonymous types.
|
// Assign names to anonymous types.
|
||||||
IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding);
|
IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding);
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1022,8 +1075,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PDOMBinding addTypeBinding(IBinding type) throws CoreException {
|
public PDOMBinding addTypeBinding(IBinding binding) throws CoreException {
|
||||||
return addBinding(type, null);
|
return addBinding(binding, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -64,7 +64,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
|
||||||
|
|
||||||
private byte annotation1= -1;
|
private byte annotation1= -1;
|
||||||
|
|
||||||
public PDOMCPPMethod(PDOMLinkage linkage, PDOMNode parent, ICPPMethod method) throws CoreException, DOMException {
|
public PDOMCPPMethod(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method) throws CoreException, DOMException {
|
||||||
super(linkage, parent, method, true);
|
super(linkage, parent, method, true);
|
||||||
|
|
||||||
Database db = getDB();
|
Database db = getDB();
|
||||||
|
|
|
@ -123,7 +123,7 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVisibility() {
|
public int getVisibility() {
|
||||||
return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION_OFFSET));
|
return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue