diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java index 72bb9beb8f3..499d867c5c2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java @@ -3113,7 +3113,9 @@ public class CPPSemantics { //derived class of B ICPPPointerToMemberType spm = (ICPPPointerToMemberType) s; ICPPPointerToMemberType tpm = (ICPPPointerToMemberType) t; - if( spm.getType().isSameType( tpm.getType() ) ){ + IType st = spm.getType(); + IType tt = tpm.getType(); + if( st != null && tt != null && st.isSameType( tt ) ){ temp = hasBaseClass( tpm.getMemberOfClass(), spm.getMemberOfClass(), false ); cost.rank = ( temp > -1 ) ? Cost.CONVERSION_RANK : Cost.NO_MATCH_RANK; cost.conversion = ( temp > -1 ) ? temp : 0; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java index 6810bc4dd6d..1afa1b4ae42 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java @@ -205,11 +205,15 @@ public class PDOMFile implements IIndexFragmentFile { } } - private PDOMName createPDOMName(IASTName name, PDOMName caller) throws CoreException { + private PDOMName createPDOMName(IASTName name, PDOMName caller) { PDOMName result= null; - PDOMBinding binding= ((WritablePDOM) pdom).addBinding(name); - if (binding != null) { - result= new PDOMName(pdom, name, this, binding, caller); + try { + PDOMBinding binding = ((WritablePDOM) pdom).addBinding(name); + if (binding != null) { + result= new PDOMName(pdom, name, this, binding, caller); + } + } catch (CoreException e) { + CCorePlugin.log(e); } return result; } @@ -325,13 +329,12 @@ public class PDOMFile implements IIndexFragmentFile { } public static IIndexFragmentFile findFile(PDOM pdom, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy) - throws CoreException { + throws CoreException { Finder finder = new Finder(pdom.getDB(), location, strategy); btree.accept(finder); int record = finder.getRecord(); return record != 0 ? new PDOMFile(pdom, record) : null; } - private static class Finder implements IBTreeVisitor { private final Database db; private final String rawKey; @@ -353,7 +356,7 @@ public class PDOMFile implements IIndexFragmentFile { this.record = record; return false; } - + public int getRecord() { return record; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index 52ffe66568a..5e440f63699 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; 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.ICPPPointerToMemberType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; @@ -128,6 +129,21 @@ public class PDOMCPPLinkage extends PDOMLinkage { // Skip parameters (TODO and others I'm sure) return null; + PDOMBinding pdomBinding = addBinding(binding); + if (pdomBinding instanceof PDOMCPPClassType) { + PDOMCPPClassType pdomClassType= (PDOMCPPClassType) pdomBinding; + IASTNode baseNode= name.getParent(); + if (baseNode instanceof ICPPASTBaseSpecifier) + addBaseClasses(pdomClassType, (ICPPASTBaseSpecifier) baseNode); + + if (binding instanceof ICPPClassType && name.isDefinition()) { + addImplicitMethods(pdomClassType, (ICPPClassType) binding); + } + } + return pdomBinding; + } + + private PDOMBinding addBinding(IBinding binding) throws CoreException { PDOMBinding pdomBinding = adaptBinding(binding); try { if (pdomBinding == null) { @@ -140,16 +156,6 @@ public class PDOMCPPLinkage extends PDOMLinkage { throw new CoreException(Util.createStatus(e)); } - if (pdomBinding instanceof PDOMCPPClassType) { - PDOMCPPClassType pdomClassType= (PDOMCPPClassType) pdomBinding; - IASTNode baseNode= name.getParent(); - if (baseNode instanceof ICPPASTBaseSpecifier) - addBaseClasses(pdomClassType, (ICPPASTBaseSpecifier) baseNode); - - if (binding instanceof ICPPClassType && name.isDefinition()) { - addImplicitMethods(pdomClassType, (ICPPClassType) binding); - } - } return pdomBinding; } @@ -397,21 +403,25 @@ public class PDOMCPPLinkage extends PDOMLinkage { } public PDOMNode addType(PDOMNode parent, IType type) throws CoreException { + if (type instanceof IProblemBinding) { + return null; + } if (type instanceof ICPPBasicType) { return new PDOMCPPBasicType(pdom, parent, (ICPPBasicType)type); - } else if (type instanceof ICPPClassType) { - // aftodo: please review, the binding may be nested in a namespace bug 162011 - // it might be necessary to create the binding for the class here. - PDOMBinding binding= adaptBinding((ICPPClassType) type); - if (binding != null) { - return binding; - } - } else if(type instanceof IEnumeration) { - PDOMBinding binding= adaptBinding((IEnumeration) type); - if (binding != null) { - return binding; - } - } else if (type instanceof ICPPPointerToMemberType) { + } + if (type instanceof ICPPClassType) { + return addBinding((ICPPClassType) type); + } + if (type instanceof IEnumeration) { + return addBinding((IEnumeration) type); + } + if (type instanceof ITypedef) { + return addBinding((ITypedef) type); + } + if (type instanceof ICPPReferenceType) { + return new PDOMCPPReferenceType(pdom, parent, (ICPPReferenceType)type); + } + if (type instanceof ICPPPointerToMemberType) { return new PDOMCPPPointerToMemberType(pdom, parent, (ICPPPointerToMemberType)type); }