1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Performance optimizations for overload resolution, bug 268383.

This commit is contained in:
Markus Schorn 2009-03-17 09:28:09 +00:00
parent 0105ad935d
commit 0abd280a88
16 changed files with 213 additions and 61 deletions

View file

@ -128,6 +128,7 @@ public class BaseTestCase extends TestCase {
case IResourceStatus.NOT_FOUND_LOCAL:
case IResourceStatus.NO_LOCATION_LOCAL:
case IResourceStatus.FAILED_READ_LOCAL:
case IResourceStatus.RESOURCE_NOT_LOCAL:
// logged by the resources plugin.
return;
}

View file

@ -1957,11 +1957,13 @@ public class CPPSemantics {
continue;
}
final IParameter[] params = function.getParameters();
int numPars = params.length;
// the index is optimized to provide the function type, try not to use the parameters
// as long as possible.
final IType[] parameterTypes = function.getType().getParameterTypes();
int numPars = parameterTypes.length;
if (numArgs < 2 && numPars == 1) {
// check for void
IType t = getNestedType(params[0].getType(), TDEF);
IType t = getNestedType(parameterTypes[0], TDEF);
if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void)
numPars= 0;
}
@ -1978,6 +1980,10 @@ public class CPPSemantics {
}
} else if (numArgs < numPars) {
// fewer arguments than parameters --> need default values
IParameter[] params = function.getParameters();
if (params.length < numPars) {
functions[i]= null;
} else {
for (int j = numArgs; j < numPars; j++) {
if (!((ICPPParameter) params[j]).hasDefaultValue()) {
functions[i] = null;
@ -1988,6 +1994,7 @@ public class CPPSemantics {
}
}
}
}
static private boolean isMatchingFunctionDeclaration(IFunction candidate, LookupData data) {
IASTNode node = data.astName.getParent();
while (node instanceof IASTName)

View file

@ -71,6 +71,7 @@ public class InternalParserUtil extends ParserFactory {
case IResourceStatus.NOT_FOUND_LOCAL:
case IResourceStatus.NO_LOCATION_LOCAL:
case IResourceStatus.FAILED_READ_LOCAL:
case IResourceStatus.RESOURCE_NOT_LOCAL:
return null;
}
throw e;

View file

@ -864,26 +864,29 @@ public class PDOM extends PlatformObject implements IPDOM {
public IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
ArrayList<IIndexFragmentBinding> result= new ArrayList<IIndexFragmentBinding>();
try {
for (PDOMLinkage linkage : getLinkageList()) {
if (filter.acceptLinkage(linkage)) {
PDOMBinding[] bindings;
PDOMBinding[] bindings= linkage.getBindingsViaCache(name, monitor);
for (PDOMBinding binding : bindings) {
if (filter.acceptBinding(binding)) {
result.add(binding);
}
}
if (!filescope) {
BindingCollector visitor = new BindingCollector(linkage, name, filter, false, true);
visitor.setMonitor(monitor);
try {
linkage.accept(visitor);
if (!filescope) {
linkage.getNestedBindingsIndex().accept(visitor);
}
}
catch (OperationCanceledException e) {
}
bindings= visitor.getBindings();
bindings= visitor.getBindings();
for (PDOMBinding binding : bindings) {
result.add(binding);
}
}
}
}
} catch (OperationCanceledException e) {
}
return result.toArray(new IIndexFragmentBinding[result.size()]);
}

View file

@ -51,6 +51,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 16;
private byte hasDeclaration= -1;
protected PDOMBinding(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {
super(linkage, parent, name);
@ -86,9 +87,17 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
}
public final boolean hasDeclaration() throws CoreException {
Database db = getDB();
return db.getInt(record + FIRST_DECL_OFFSET) != 0
|| db.getInt(record + FIRST_DEF_OFFSET) != 0;
if (hasDeclaration == -1) {
final Database db = getDB();
if (db.getInt(record + FIRST_DECL_OFFSET) != 0
|| db.getInt(record + FIRST_DEF_OFFSET) != 0) {
hasDeclaration= 1;
return true;
}
hasDeclaration= 0;
return false;
}
return hasDeclaration != 0;
}
public void addDeclaration(PDOMName name) throws CoreException {

View file

@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@ -33,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
import org.eclipse.cdt.core.index.IIndexLinkage;
import org.eclipse.cdt.core.parser.util.CharArrayMap;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -43,6 +47,7 @@ import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.cdt.internal.core.pdom.db.IString;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* This class represents a collection of symbols that can be linked together at
@ -413,4 +418,39 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
public PDOMBinding addUnknownValue(IBinding binding) throws CoreException {
return null;
}
/**
* Returns the list of global bindings for the given name.
* @throws CoreException
*/
public PDOMBinding[] getBindingsViaCache(char[] name, IProgressMonitor monitor) throws CoreException {
CharArrayMap<PDOMBinding[]> map = getBindingMap();
synchronized(map) {
PDOMBinding[] result= map.get(name);
if (result != null)
return result;
}
BindingCollector visitor = new BindingCollector(this, name, null, false, true);
visitor.setMonitor(monitor);
getIndex().accept(visitor);
PDOMBinding[] result= visitor.getBindings();
synchronized(map) {
map.put(name, result);
}
return result;
}
private CharArrayMap<PDOMBinding[]> getBindingMap() {
final Integer key= getRecord();
final PDOM pdom = getPDOM();
@SuppressWarnings("unchecked")
Reference<CharArrayMap<PDOMBinding[]>> cached= (Reference<CharArrayMap<PDOMBinding[]>>) pdom.getCachedResult(key);
CharArrayMap<PDOMBinding[]> map= cached == null ? null : cached.get();
if (map == null) {
map= new CharArrayMap<PDOMBinding[]>();
pdom.putCachedResult(key, new SoftReference<CharArrayMap<?>>(map));
}
return map;
}
}

View file

@ -43,6 +43,11 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
private static final int CONST = 0x1;
private static final int VOLATILE = 0x2;
// cached values
private byte flags= -1;
private IType targetType;
public PDOMPointerType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@ -84,10 +89,20 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
}
private byte getFlags() throws CoreException {
return getDB().getByte(record + FLAGS);
if (flags == -1) {
flags= getDB().getByte(record + FLAGS);
}
return flags;
}
public IType getType() {
if (targetType == null)
targetType= readType();
return targetType;
}
private IType readType() {
try {
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;

View file

@ -43,6 +43,10 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
private static final int VOLATILE = 0x2;
private static final int RESTRICT = 0x4;
// cached values
private byte flags= -1;
private IType targetType;
public PDOMQualifierType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@ -86,6 +90,13 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
}
public IType getType() {
if (targetType == null)
targetType= readType();
return targetType;
}
private IType readType() {
try {
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
@ -96,7 +107,10 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
}
private byte getFlags() throws CoreException {
return getDB().getByte(record + FLAGS);
if (flags == -1) {
flags= getDB().getByte(record + FLAGS);
}
return flags;
}
public boolean isConst() {

View file

@ -52,6 +52,8 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE= PDOMNode.RECORD_SIZE + 8;
private IType[] parameterTypes;
public PDOMCFunctionType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@ -147,7 +149,15 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
return false;
}
public IType[] getParameterTypes() {
public final IType[] getParameterTypes() {
if (parameterTypes == null)
parameterTypes= readParameterTypes();
// public method, it is safer to clone.
return parameterTypes.clone();
}
private final IType[] readParameterTypes() {
final List<IType> result= new ArrayList<IType>();
try {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + TYPELIST, true);

View file

@ -39,6 +39,7 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
private static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 4;
protected short fFlags= -1;
protected short fType= -1;
public PDOMCPPBasicType(PDOMLinkage linkage, int record) {
super(linkage, record);
@ -93,13 +94,16 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
}
public int getType() {
if (fType == -1) {
try {
return getDB().getShort(record + TYPE_ID);
fType= getDB().getShort(record + TYPE_ID);
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
fType= 0;
}
}
return fType;
}
@Deprecated
public IASTExpression getValue() throws DOMException {

View file

@ -30,7 +30,7 @@ class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor {
}
public boolean isExplicit() throws DOMException {
return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET);
return getBit(getAnnotation1(), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET);
}
@Override

View file

@ -34,7 +34,7 @@ class PDOMCPPConstructorTemplate extends PDOMCPPMethodTemplate implements
}
public boolean isExplicit() throws DOMException {
return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET);
return getBit(getAnnotation1(), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET);
}
@Override

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -71,7 +72,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
* Offset of annotation information (relative to the beginning of the
* record).
*/
protected static final int ANNOTATION = PDOMCPPBinding.RECORD_SIZE + 20; // byte
private static final int ANNOTATION = PDOMCPPBinding.RECORD_SIZE + 20; // byte
/**
* The size in bytes of a PDOMCPPFunction record in the database.
@ -79,6 +80,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 21;
private byte annotation= -1;
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function, boolean setTypes) throws CoreException, DOMException {
super(linkage, parent, function.getNameCharArray());
Database db = getDB();
@ -129,6 +132,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
final Database db = getDB();
db.putByte(record + ANNOTATION, newAnnotation);
annotation= newAnnotation;
int oldRec = db.getInt(record+EXCEPTION_SPEC);
storeExceptionSpec(db, func);
@ -166,6 +170,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
private PDOMCPPFunctionType setType(ICPPFunctionType ft) throws CoreException {
PDOMCPPFunctionType pft = (PDOMCPPFunctionType) getLinkage().addType(this, ft);
getDB().putInt(record + FUNCTION_TYPE, pft.getRecord());
getPDOM().putCachedResult(record, pft, true);
return pft;
}
@ -204,11 +209,17 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
public boolean isInline() throws DOMException {
return getBit(getByte(record + ANNOTATION), PDOMCAnnotation.INLINE_OFFSET);
return getBit(getAnnotation(), PDOMCAnnotation.INLINE_OFFSET);
}
final protected byte getAnnotation() {
if (annotation == -1)
annotation= getByte(record + ANNOTATION);
return annotation;
}
public boolean isExternC() throws DOMException {
return getBit(getByte(record + ANNOTATION), PDOMCPPAnnotation.EXTERN_C_OFFSET);
return getBit(getAnnotation(), PDOMCPPAnnotation.EXTERN_C_OFFSET);
}
public boolean isMutable() throws DOMException {
@ -235,7 +246,17 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
}
public ICPPFunctionType getType() {
public final ICPPFunctionType getType() {
final PDOM pdom= getPDOM();
ICPPFunctionType ftype= (ICPPFunctionType) pdom.getCachedResult(record);
if (ftype == null) {
ftype= readFunctionType();
pdom.putCachedResult(record, ftype, false);
}
return ftype;
}
private final ICPPFunctionType readFunctionType() {
try {
int offset= getDB().getInt(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCPPFunctionType(getLinkage(), offset);
@ -251,7 +272,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
public boolean isExtern() throws DOMException {
return getBit(getByte(record + ANNOTATION), PDOMCAnnotation.EXTERN_OFFSET);
return getBit(getAnnotation(), PDOMCAnnotation.EXTERN_OFFSET);
}
public boolean isRegister() throws DOMException {
@ -260,11 +281,11 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
public boolean isStatic() throws DOMException {
return getBit(getByte(record + ANNOTATION), PDOMCAnnotation.STATIC_OFFSET);
return getBit(getAnnotation(), PDOMCAnnotation.STATIC_OFFSET);
}
public boolean takesVarArgs() throws DOMException {
return getBit(getByte(record + ANNOTATION), PDOMCAnnotation.VARARGS_OFFSET);
return getBit(getAnnotation(), PDOMCAnnotation.VARARGS_OFFSET);
}
@Override

View file

@ -46,7 +46,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
* Offset of remaining annotation information (relative to the beginning of
* the record).
*/
protected static final int ANNOTATION1 = PDOMCPPFunction.RECORD_SIZE; // byte
private static final int ANNOTATION1 = PDOMCPPFunction.RECORD_SIZE; // byte
/**
* The size in bytes of a PDOMCPPMethod record in the database.
@ -59,14 +59,16 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
*/
private static final int CV_OFFSET = PDOMCPPAnnotation.MAX_EXTRA_OFFSET + 1;
private byte annotation1= -1;
public PDOMCPPMethod(PDOMLinkage linkage, PDOMNode parent, ICPPMethod method) throws CoreException, DOMException {
super(linkage, parent, method, true);
Database db = getDB();
try {
byte annotation= PDOMCPPAnnotation.encodeExtraAnnotation(method);
db.putByte(record + ANNOTATION1, annotation);
annotation1= PDOMCPPAnnotation.encodeExtraAnnotation(method);
db.putByte(record + ANNOTATION1, annotation1);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
@ -81,8 +83,11 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
if (newBinding instanceof ICPPMethod) {
ICPPMethod method= (ICPPMethod) newBinding;
super.update(linkage, newBinding);
annotation1= -1;
try {
getDB().putByte(record + ANNOTATION1, PDOMCPPAnnotation.encodeExtraAnnotation(method));
final byte annot = PDOMCPPAnnotation.encodeExtraAnnotation(method);
getDB().putByte(record + ANNOTATION1, annot);
annotation1= annot;
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
@ -100,15 +105,21 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
public boolean isVirtual() throws DOMException {
return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.VIRTUAL_OFFSET);
return getBit(getAnnotation1(), PDOMCPPAnnotation.VIRTUAL_OFFSET);
}
protected byte getAnnotation1() {
if (annotation1 == -1)
annotation1= getByte(record + ANNOTATION1);
return annotation1;
}
public boolean isPureVirtual() throws DOMException {
return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.PURE_VIRTUAL_OFFSET);
return getBit(getAnnotation1(), PDOMCPPAnnotation.PURE_VIRTUAL_OFFSET);
}
public boolean isDestructor() throws DOMException {
return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.DESTRUCTOR_OFFSET);
return getBit(getAnnotation1(), PDOMCPPAnnotation.DESTRUCTOR_OFFSET);
}
@Override
@ -117,7 +128,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
public boolean isImplicit() {
return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET);
return getBit(getAnnotation1(), PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET);
}
@Override
@ -149,7 +160,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
public int getVisibility() throws DOMException {
return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION));
return PDOMCPPAnnotation.getVisibility(getAnnotation());
}
public ICPPClassType getClassOwner() throws DOMException {
@ -162,11 +173,11 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
public boolean isConst() {
return getBit(getByte(record + ANNOTATION1), PDOMCAnnotation.CONST_OFFSET + CV_OFFSET);
return getBit(getAnnotation1(), PDOMCAnnotation.CONST_OFFSET + CV_OFFSET);
}
public boolean isVolatile() {
return getBit(getByte(record + ANNOTATION1), PDOMCAnnotation.VOLATILE_OFFSET + CV_OFFSET);
return getBit(getAnnotation1(), PDOMCAnnotation.VOLATILE_OFFSET + CV_OFFSET);
}
@Override

View file

@ -34,7 +34,7 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
* Offset of remaining annotation information (relative to the beginning of
* the record).
*/
protected static final int ANNOTATION1 = PDOMCPPFunctionTemplate.RECORD_SIZE; // byte
private static final int ANNOTATION1 = PDOMCPPFunctionTemplate.RECORD_SIZE; // byte
/**
* The size in bytes of a PDOMCPPMethodTemplate record in the database.
@ -47,6 +47,8 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
*/
private static final int CV_OFFSET = PDOMCPPAnnotation.MAX_EXTRA_OFFSET + 1;
private byte annotation1= -1;
public PDOMCPPMethodTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method)
throws CoreException, DOMException {
super(linkage, parent, (ICPPFunctionTemplate) method);
@ -79,15 +81,21 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
}
public boolean isDestructor() throws DOMException {
return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.DESTRUCTOR_OFFSET);
return getBit(getAnnotation1(), PDOMCPPAnnotation.DESTRUCTOR_OFFSET);
}
final protected byte getAnnotation1() {
if (annotation1 == -1)
annotation1= getByte(record + ANNOTATION1);
return annotation1;
}
public boolean isImplicit() {
return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET);
return getBit(getAnnotation1(), PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET);
}
public boolean isVirtual() throws DOMException {
return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.VIRTUAL_OFFSET);
return getBit(getAnnotation1(), PDOMCPPAnnotation.VIRTUAL_OFFSET);
}
public ICPPClassType getClassOwner() throws DOMException {
@ -95,15 +103,15 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
}
public int getVisibility() throws DOMException {
return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION));
return PDOMCPPAnnotation.getVisibility(getAnnotation());
}
public boolean isConst() {
return getBit(getByte(record + ANNOTATION1), PDOMCAnnotation.CONST_OFFSET + CV_OFFSET);
return getBit(getAnnotation1(), PDOMCAnnotation.CONST_OFFSET + CV_OFFSET);
}
public boolean isVolatile() {
return getBit(getByte(record + ANNOTATION1), PDOMCAnnotation.VOLATILE_OFFSET + CV_OFFSET);
return getBit(getAnnotation1(), PDOMCAnnotation.VOLATILE_OFFSET + CV_OFFSET);
}
@Override

View file

@ -9,7 +9,6 @@
* Markus Schorn - initial API and implementation
* Bryan Wilkinson (QNX)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
@ -36,6 +35,8 @@ class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType, ITypeC
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 4;
private IType targetType;
public PDOMCPPReferenceType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@ -71,6 +72,13 @@ class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType, ITypeC
}
public IType getType() {
if (targetType == null)
targetType= readType();
return targetType;
}
private IType readType() {
try {
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;