diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 9b956833e27..fe064944f5f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -8895,5 +8895,24 @@ public class AST2CPPTests extends AST2BaseTest { IFunction f= bh.assertNonProblem("constBegin(); //ref", 10); bh.assertProblem("begin(); //ref", 5); } - + + // template class PE { + // explicit operator bool() const; + // }; + // template class P { + // operator bool() const; + // }; + // void fint(int); + // void test() { + // PE pe; + // P p; + // fint(pe + pe); // problem + // fint(p + p); // converted to boolean and then int. + // }; + public void testExplicitConversionOperators() throws Exception { + String code= getAboveComment(); + BindingAssertionHelper bh= new BindingAssertionHelper(code, true); + bh.assertProblem("fint(pe + pe);", 4); + bh.assertNonProblem("fint(p + p);", 4); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java index 0ef2ccfccfd..96c4e5468b1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java @@ -44,7 +44,10 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTProblem; * * @noextend This interface is not intended to be extended by clients. * @noinstantiate This class is not intended to be instantiated by clients. + * @deprecated The class is provided for testing purposes, only. It should not be used by clients. + * Within CDT it is recommended to use {@link ASTSignatureUtil}, instead. */ +@Deprecated public class ASTSignatureUtil { private static final String COMMA_SPACE = ", "; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java index cd3db295af1..7ccdc403f85 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java @@ -17,9 +17,4 @@ package org.eclipse.cdt.core.dom.ast.cpp; */ public interface ICPPConstructor extends ICPPMethod { public static final ICPPConstructor [] EMPTY_CONSTRUCTOR_ARRAY = new ICPPConstructor[0]; - /** - * Whether or not this constructor was declared as explicit - */ - boolean isExplicit(); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java index ca29b804f23..abbf0ad6cc2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java @@ -39,6 +39,12 @@ public interface ICPPMethod extends ICPPFunction, ICPPMember { */ public boolean isImplicit(); + /** + * Returns whether this is an explicit constructor or an explicit conversion operator. + * @since 5.3 + */ + boolean isExplicit(); + /** * Returns whether this is a pure abstract method * @since 5.1 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java index 4ee15d3beaa..85638c073d9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java @@ -326,6 +326,9 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I public boolean isImplicit() { return false; } + public boolean isExplicit() { + return false; + } public boolean hasDefaultValue() { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java index ed5d0f52881..e832fe370cb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java @@ -11,9 +11,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; +import org.eclipse.cdt.internal.core.model.ASTStringUtil; /** * Base for all c++ declaration specifiers @@ -113,8 +113,11 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST other.setOffsetAndLength(this); } - @Override + /** + * Provided for debugging purposes, only. + */ + @Override public String toString() { - return ASTSignatureUtil.getSignature(this); + return ASTStringUtil.getSignatureString(this, null); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructor.java index 95e3fe44163..82852ac36c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructor.java @@ -11,9 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTNode; -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.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; @@ -24,30 +22,10 @@ public class CPPConstructor extends CPPMethod implements ICPPConstructor { public CPPConstructorProblem(ICPPClassType owner, IASTNode node, int id, char[] arg) { super(owner, node, id, arg); } - - public boolean isExplicit() { - return false; - } } - /** - * @param declarator - */ public CPPConstructor(ICPPASTFunctionDeclarator declarator) { super(declarator); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor#isExplicit() - */ - public boolean isExplicit() { - IASTDeclaration decl= getPrimaryDeclaration(); - if (decl != null) { - ICPPASTDeclSpecifier declspec= getDeclSpec(decl); - if (declspec != null) { - return declspec.isExplicit(); - } - } - return false; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java index a62d8ff66d3..e3cba7d043a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorInstance.java @@ -24,8 +24,4 @@ public class CPPConstructorInstance extends CPPMethodInstance implements ICPPCon CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args) { super(orig, owner, tpmap, args); } - - public boolean isExplicit() { - return ((ICPPConstructor) getTemplateDefinition()).isExplicit(); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java index 9f067d52179..5e746dc8145 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorSpecialization.java @@ -25,11 +25,4 @@ public class CPPConstructorSpecialization extends CPPMethodSpecialization ICPPTemplateParameterMap argMap) { super(orig, owner, argMap); } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor#isExplicit() - */ - public boolean isExplicit() { - return ((ICPPConstructor)getSpecializedBinding()).isExplicit(); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplate.java index 6c8add94b5c..5e472d37f25 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplate.java @@ -18,14 +18,4 @@ public class CPPConstructorTemplate extends CPPMethodTemplate implements ICPPCon public CPPConstructorTemplate(IASTName name) { super(name); } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor#isExplicit() - */ - public boolean isExplicit() { - // mstodo fix that - // TODO Auto-generated method stub - return false; - } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java index 1dd24745147..fa41772cb27 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPConstructorTemplateSpecialization.java @@ -25,11 +25,4 @@ public class CPPConstructorTemplateSpecialization extends CPPMethodTemplateSpeci ICPPClassType owner, ICPPTemplateParameterMap tpmap) { super(original, owner, tpmap); } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor#isExplicit() - */ - public boolean isExplicit() { - return ((ICPPConstructor)getSpecializedBinding()).isExplicit(); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java index eb06acaedea..a30e501630b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java @@ -30,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; 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.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; @@ -178,15 +179,10 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition do { if (name != null) { IASTNode parent = name.getParent(); - while(!(parent instanceof IASTDeclaration)) + while (parent != null && !(parent instanceof IASTDeclaration)) parent = parent.getParent(); - IASTDeclSpecifier declSpec = null; - if (parent instanceof IASTSimpleDeclaration) { - declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier(); - } else if (parent instanceof IASTFunctionDefinition) { - declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier(); - } + IASTDeclSpecifier declSpec = getDeclSpecifier((IASTDeclaration) parent); if (declSpec != null && declSpec.getStorageClass() == storage) { return true; } @@ -199,6 +195,16 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition return false; } + protected ICPPASTDeclSpecifier getDeclSpecifier(IASTDeclaration decl) { + if (decl instanceof IASTSimpleDeclaration) { + return (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier(); + } + if (decl instanceof IASTFunctionDefinition) { + return (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier(); + } + return null; + } + public IBinding resolveParameter(CPPParameter param) { int pos= param.getParameterPosition(); @@ -282,15 +288,10 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition do { if (name != null) { IASTNode parent = name.getParent(); - while(!(parent instanceof IASTDeclaration)) - parent = parent.getParent(); + while (parent != null && !(parent instanceof IASTDeclaration)) + parent = parent.getParent(); - IASTDeclSpecifier declSpec = null; - if (parent instanceof IASTSimpleDeclaration) { - declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier(); - } else if (parent instanceof IASTFunctionDefinition) { - declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier(); - } + IASTDeclSpecifier declSpec = getDeclSpecifier((IASTDeclaration) parent); if (declSpec != null && declSpec.isInline()) return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitConstructor.java index 0a25999a29a..98136db3aad 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitConstructor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation 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 @@ -11,9 +11,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; @@ -33,8 +33,4 @@ public class CPPImplicitConstructor extends CPPImplicitMethod implements ICPPCon IType returnType= new CPPBasicType(Kind.eUnspecified, 0); return CPPVisitor.createImplicitFunctionType(returnType, params, false, false); } - - public boolean isExplicit() { - return false; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java index ad901405539..4747a21ef10 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java @@ -172,6 +172,10 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod return getPrimaryDeclaration() == null; } + public boolean isExplicit() { + return false; + } + public boolean isPureVirtual() { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java index e9a5d0423b1..f3929ac6fbf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java @@ -246,4 +246,14 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { return false; } + public boolean isExplicit() { + IASTDeclaration decl= getPrimaryDeclaration(); + if (decl != null) { + ICPPASTDeclSpecifier declspec= getDeclSpec(decl); + if (declspec != null) { + return declspec.isExplicit(); + } + } + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java index 1c687d96f0e..7fd74322ca2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java @@ -48,6 +48,10 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod public boolean isPureVirtual() { return ((ICPPMethod)getTemplateDefinition()).isPureVirtual(); } + + public boolean isExplicit() { + return ((ICPPMethod) getTemplateDefinition()).isExplicit(); + } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java index a56ac19b637..dc6ba8e3d42 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java @@ -73,6 +73,10 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization return false; } + public boolean isExplicit() { + return ((ICPPMethod)getSpecializedBinding()).isExplicit(); + } + public boolean isImplicit() { return ((ICPPMethod) getSpecializedBinding()).isImplicit(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java index bd2f6ff79e2..60870ade96e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplate.java @@ -21,6 +21,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; +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.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; @@ -139,18 +141,25 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod } public boolean isVirtual() { - // TODO Auto-generated method stub - return false; - } + IASTDeclaration decl = getPrimaryDeclaration(); + if (decl instanceof ICPPASTTemplateDeclaration) { + ICPPASTDeclSpecifier declSpec= getDeclSpecifier(((ICPPASTTemplateDeclaration) decl).getDeclaration()); + if (declSpec != null) { + return declSpec.isVirtual(); + } + } + return false; + } @Override public boolean isInline() { - IASTDeclaration decl = getPrimaryDeclaration(); - if( decl instanceof ICPPASTTemplateDeclaration && ((ICPPASTTemplateDeclaration)decl).getDeclaration() instanceof IASTFunctionDefinition ) - return true; + IASTDeclaration decl = getPrimaryDeclaration(); + if (decl instanceof ICPPASTTemplateDeclaration + && ((ICPPASTTemplateDeclaration) decl).getDeclaration() instanceof IASTFunctionDefinition) + return true; - return super.isInline(); - } + return super.isInline(); + } public boolean isDestructor() { char[] name = getNameCharArray(); @@ -163,9 +172,34 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod public boolean isImplicit() { return false; } - - public boolean isPureVirtual() { + + public boolean isExplicit() { + IASTDeclaration decl = getPrimaryDeclaration(); + if (decl instanceof ICPPASTTemplateDeclaration) { + ICPPASTDeclSpecifier declSpec= getDeclSpecifier(((ICPPASTTemplateDeclaration) decl).getDeclaration()); + if (declSpec != null) { + return declSpec.isExplicit(); + } + } return false; } + public boolean isPureVirtual() { + if (declarations != null && declarations.length > 0) { + IASTName decl= declarations[0]; + if (decl != null) { + IASTNode parent = decl.getParent(); + while (!(parent instanceof IASTDeclarator) && parent != null) + parent = parent.getParent(); + + if (parent instanceof IASTDeclarator) { + IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) parent); + if (dtor instanceof ICPPASTFunctionDeclarator) { + return ((ICPPASTFunctionDeclarator) dtor).isPureVirtual(); + } + } + } + } + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java index 5ec15ba6be2..7ea5aff8d97 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodTemplateSpecialization.java @@ -28,14 +28,16 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali } public boolean isVirtual() { - // TODO Auto-generated method stub + IBinding m = getSpecializedBinding(); + if (m instanceof ICPPMethod) + return ((ICPPMethod) m).isVirtual(); return false; } public int getVisibility() { IBinding m = getSpecializedBinding(); - if( m instanceof ICPPMethod ) - return ((ICPPMethod)m).getVisibility(); + if (m instanceof ICPPMethod) + return ((ICPPMethod) m).getVisibility(); return 0; } @@ -52,10 +54,23 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali } public boolean isImplicit() { + IBinding m = getSpecializedBinding(); + if (m instanceof ICPPMethod) + return ((ICPPMethod) m).isImplicit(); + return false; + } + + public boolean isExplicit() { + IBinding m = getSpecializedBinding(); + if (m instanceof ICPPMethod) + return ((ICPPMethod) m).isExplicit(); return false; } public boolean isPureVirtual() { + IBinding m = getSpecializedBinding(); + if (m instanceof ICPPMethod) + return ((ICPPMethod) m).isPureVirtual(); return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java index 56a38ea8290..eb9584c34b8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java @@ -39,6 +39,7 @@ 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.ICPPPointerToMemberType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; +import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArithmeticConversion; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBuiltinParameter; @@ -348,14 +349,11 @@ class BuiltinOperators { IType t2= SemanticUtil.getNestedType(memPtr.getMemberOfClass(), TDEF); if (t2 instanceof ICPPClassType) { ICPPClassType c2= (ICPPClassType) t2; - try { - if (SemanticUtil.calculateInheritanceDepth(c1, c2) >= 0) { - IType cvt= SemanticUtil.getNestedType(memPtr.getType(), TDEF); - IType rt= new CPPReferenceType( - SemanticUtil.addQualifiers(cvt, cv1.isConst(), cv1.isVolatile()), false); - addFunction(rt, clsPtr, memPtr); - } - } catch (DOMException e) { + if (SemanticUtil.calculateInheritanceDepth(c1, c2) >= 0) { + IType cvt= SemanticUtil.getNestedType(memPtr.getType(), TDEF); + IType rt= new CPPReferenceType( + SemanticUtil.addQualifiers(cvt, cv1.isConst(), cv1.isVolatile()), false); + addFunction(rt, clsPtr, memPtr); } } } @@ -646,12 +644,19 @@ class BuiltinOperators { try { ICPPMethod[] ops = SemanticUtil.getConversionOperators((ICPPClassType) type); result= new IType[ops.length]; - for (int i = 0; i < result.length; i++) { - final ICPPFunctionType functionType = ops[i].getType(); + int j= -1; + for (ICPPMethod op : ops) { + if (op.isExplicit()) + continue; + final ICPPFunctionType functionType = op.getType(); if (functionType != null) { - result[i]= functionType.getReturnType(); + IType retType= functionType.getReturnType(); + if (retType != null) { + result[++j]= retType; + } } } + result= ArrayUtil.trimAt(IType.class, result, j); } catch (DOMException e) { } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 658abb8b37b..8005644e6e4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -2950,6 +2950,32 @@ public class CPPSemantics { type = SemanticUtil.getNestedType(((ICPPVariable) binding).getType(), TDEF | CVTYPE); if (!(type instanceof ICPPClassType)) return null; + + // Copy initialization + if (initializer instanceof IASTEqualsInitializer) { + IASTEqualsInitializer eqInit= (IASTEqualsInitializer) initializer; + IASTInitializerClause initClause = eqInit.getInitializerClause(); + IType sourceType= null; + boolean isLValue= false; + if (initClause instanceof IASTExpression) { + final IASTExpression expr = (IASTExpression) initClause; + isLValue= expr.isLValue(); + sourceType= SemanticUtil.getSimplifiedType(expr.getExpressionType()); + } else if (initClause instanceof ICPPASTInitializerList) { + sourceType= new InitializerListType((ICPPASTInitializerList) initClause); + } + if (sourceType != null) { + Cost c= Conversions.checkUserDefinedConversionSequence(isLValue, sourceType, type, false, false); + if (c.converts()) { + IFunction f= c.getUserDefinedConversion(); + if (f instanceof ICPPConstructor) + return (ICPPConstructor) f; + } + return null; + } + } + + // Direct Initialization ICPPClassType classType = (ICPPClassType) type; CPPASTName astName = new CPPASTName(); astName.setName(classType.getNameCharArray()); @@ -2961,9 +2987,7 @@ public class CPPSemantics { LookupData data = new LookupData(astName); if (initializer == null) { data.setFunctionArguments(IASTExpression.EMPTY_EXPRESSION_ARRAY); - } else if (initializer instanceof IASTEqualsInitializer) { - data.setFunctionArguments(((IASTEqualsInitializer) initializer).getInitializerClause()); - } else if (initializer instanceof ICPPASTConstructorInitializer) { + } else if (initializer instanceof ICPPASTConstructorInitializer) { data.setFunctionArguments(((ICPPASTConstructorInitializer) initializer).getArguments()); } else { return null; @@ -3195,6 +3219,8 @@ public class CPPSemantics { // 13.3.1.1.2 call to object of class type ICPPMethod[] ops = SemanticUtil.getConversionOperators(callToObjectOfClassType); for (ICPPMethod op : ops) { + if (op.isExplicit()) + continue; IFunctionType ft= op.getType(); if (ft != null) { IType rt= SemanticUtil.getNestedType(ft.getReturnType(), SemanticUtil.TDEF); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java index b718449ef4c..a35c4e5993a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java @@ -126,8 +126,8 @@ public class Conversions { } } // ... or has a class type (i.e., T2 is a class type), where T1 is not reference-related to T2, and can be - // implicitly converted to an lvalue of type �cv3 T3,� where �cv1 T1� is reference-compatible with - // �cv3 T3� (this conversion is selected by enumerating the applicable conversion functions (13.3.1.6) + // implicitly converted to an lvalue of type 'cv3 T3', where 'cv1 T1' is reference-compatible with + // 'cv3 T3' (this conversion is selected by enumerating the applicable conversion functions (13.3.1.6) // and choosing the best one through overload resolution (13.3)), if (T2 instanceof ICPPClassType && udc != UDCMode.noUDC && isReferenceRelated(T1, T2) < 0) { Cost cost= conversionFuncForDirectReference(cv1T1, cv2T2, T2, true); @@ -340,7 +340,7 @@ public class Conversions { return Cost.NO_CONVERSION; } - static IType getInitListType(IType target) throws DOMException { + static IType getInitListType(IType target) { if (target instanceof ICPPClassType && target instanceof ICPPTemplateInstance) { ICPPTemplateInstance inst = (ICPPTemplateInstance) target; if (CharArrayUtils.equals(INITIALIZER_LIST_NAME, inst.getNameCharArray())) { @@ -372,9 +372,8 @@ public class Conversions { *
  • EQ 0 if cv1 == cv2 *
  • LT -1 if cv1 is less qualified than cv2 or not comparable * - * @throws DOMException */ - private static final int compareQualifications(IType t1, IType t2) throws DOMException { + private static final int compareQualifications(IType t1, IType t2) { CVQualifier cv1= getCVQualifier(t1); CVQualifier cv2= getCVQualifier(t2); @@ -407,7 +406,7 @@ public class Conversions { * Note this is not a symmetric relation. * @return inheritance distance, or -1, if cv1t1 is not reference-related to cv2t2 */ - private static final int isReferenceRelated(IType cv1Target, IType cv2Source) throws DOMException { + private static final int isReferenceRelated(IType cv1Target, IType cv2Source) { IType t= SemanticUtil.getNestedType(cv1Target, TDEF | REF); IType s= SemanticUtil.getNestedType(cv2Source, TDEF | REF); @@ -458,7 +457,7 @@ public class Conversions { * @return The cost for converting or null if cv1t1 is not * reference-compatible with cv2t2 */ - private static final Cost isReferenceCompatible(IType cv1Target, IType cv2Source, boolean isImpliedObject) throws DOMException { + private static final Cost isReferenceCompatible(IType cv1Target, IType cv2Source, boolean isImpliedObject) { int inheritanceDist= isReferenceRelated(cv1Target, cv2Source); if (inheritanceDist < 0) return null; @@ -483,10 +482,9 @@ public class Conversions { * @param isImplicitThis handles the special case when members of different * classes are nominated via using-declarations. In such a situation the derived to * base conversion does not cause any costs. - * @throws DOMException */ private static final Cost checkStandardConversionSequence(IType source, boolean isLValue, IType target, - boolean isImplicitThis) throws DOMException { + boolean isImplicitThis) { final Cost cost= new Cost(source, target, Rank.IDENTITY); if (lvalue_to_rvalue(cost, isLValue)) return cost; @@ -533,7 +531,7 @@ public class Conversions { if (s instanceof ICPPClassType) { // 13.3.1.5 Initialization by conversion function - return initializationByConversion(source, (ICPPClassType) s, target); + return initializationByConversion(source, (ICPPClassType) s, target, isDirect); } return Cost.NO_CONVERSION; } @@ -669,6 +667,8 @@ public class Conversions { CPPTemplates.instantiateConversionTemplates(ops, target); for (final ICPPMethod op : ops) { if (op != null && !(op instanceof IProblemBinding)) { + if (op.isExplicit()) + continue; final IType returnType = op.getType().getReturnType(); final IType uqReturnType= getNestedType(returnType, REF | TDEF | CVTYPE); final int dist = SemanticUtil.calculateInheritanceDepth(uqReturnType, t); @@ -705,19 +705,25 @@ public class Conversions { /** * 13.3.1.5 Initialization by conversion function [over.match.conv] */ - private static Cost initializationByConversion(IType source, ICPPClassType s, IType target) throws DOMException { + private static Cost initializationByConversion(IType source, ICPPClassType s, IType target, boolean direct) throws DOMException { ICPPMethod[] ops = SemanticUtil.getConversionOperators(s); CPPTemplates.instantiateConversionTemplates(ops, target); FunctionCost cost1= null; Cost cost2= null; for (final ICPPMethod op : ops) { if (op != null && !(op instanceof IProblemBinding)) { + final boolean isExplicitConversion= op.isExplicit(); + if (isExplicitConversion && !direct) + continue; + final IType returnType = op.getType().getReturnType(); IType uqReturnType= getNestedType(returnType, TDEF | ALLCVQ); boolean isLValue = uqReturnType instanceof ICPPReferenceType && !((ICPPReferenceType) uqReturnType).isRValueReference(); Cost c2= checkImplicitConversionSequence(target, uqReturnType, isLValue, UDCMode.noUDC, false); if (c2.converts()) { + if (isExplicitConversion && c2.getRank() != Rank.IDENTITY) + continue; ICPPFunctionType ftype = op.getType(); IType implicitType= CPPSemantics.getImplicitType(op, ftype.isConst(), ftype.isVolatile()); final Cost udcCost = isReferenceCompatible(getNestedType(implicitType, TDEF | REF), source, true); @@ -749,7 +755,7 @@ public class Conversions { * [4.2] array-to-ptr * [4.3] function-to-ptr */ - private static final boolean lvalue_to_rvalue(final Cost cost, boolean isLValue) throws DOMException { + private static final boolean lvalue_to_rvalue(final Cost cost, boolean isLValue) { // target should not be a reference here. boolean isConverted= false; IType target = getNestedType(cost.target, REF | TDEF); @@ -824,9 +830,8 @@ public class Conversions { /** * [4.4] Qualifications * @param cost - * @throws DOMException */ - private static final boolean qualificationConversion(Cost cost) throws DOMException{ + private static final boolean qualificationConversion(Cost cost) { IType s = cost.source; IType t = cost.target; boolean constInEveryCV2k = true; @@ -894,9 +899,8 @@ public class Conversions { * following that can hold it: int, unsigned int, long unsigned long. * 4.5-4 bool can be promoted to int * 4.6 float can be promoted to double - * @throws DOMException */ - private static final boolean promotion(Cost cost) throws DOMException{ + private static final boolean promotion(Cost cost) { IType src = cost.source; IType trg = cost.target; @@ -980,7 +984,7 @@ public class Conversions { * [4.10] Pointer conversions * [4.11] Pointer to member conversions */ - private static final boolean conversion(Cost cost, boolean forImplicitThis) throws DOMException{ + private static final boolean conversion(Cost cost, boolean forImplicitThis){ final IType s = cost.source; final IType t = cost.target; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Cost.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Cost.java index 7625acfa24d..91f4a0fdd62 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Cost.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Cost.java @@ -15,8 +15,8 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; -import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; +import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; @@ -259,4 +259,8 @@ class Cost { public void setCouldNarrow() { fCouldNarrow= true; } + + public ICPPFunction getUserDefinedConversion() { + return fUserDefinedConversion; + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java index 74fd02b0e89..6f8dc782b40 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java @@ -537,14 +537,12 @@ public class SemanticUtil { * @param baseClass the class to find in the inheritance graph * @return the number of edges in the inheritance graph, or -1 if the specified classes have * no inheritance relation - * @throws DOMException */ - public static final int calculateInheritanceDepth(IType type, IType baseClass) throws DOMException { + public static final int calculateInheritanceDepth(IType type, IType baseClass) { return calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, type, baseClass); } - private static final int calculateInheritanceDepth(int maxdepth, IType type, IType baseClass) - throws DOMException { + private static final int calculateInheritanceDepth(int maxdepth, IType type, IType baseClass) { if (type == baseClass || type.isSameType(baseClass)) { return 0; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructor.java index 97800218ba4..0bc56b234ba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructor.java @@ -18,8 +18,4 @@ class CompositeCPPConstructor extends CompositeCPPMethod implements ICPPConstruc public CompositeCPPConstructor(ICompositesFactory cf, ICPPFunction rbinding) { super(cf, rbinding); } - - public boolean isExplicit() { - return ((ICPPConstructor)rbinding).isExplicit(); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorInstance.java index 3076796d69b..9aa4982cc59 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorInstance.java @@ -17,8 +17,4 @@ public class CompositeCPPConstructorInstance extends CompositeCPPMethodInstance public CompositeCPPConstructorInstance(ICompositesFactory cf, ICPPConstructor rbinding) { super(cf, rbinding); } - - public boolean isExplicit() { - return ((ICPPConstructor)rbinding).isExplicit(); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorSpecialization.java index b7e07b44aba..45900be3821 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorSpecialization.java @@ -13,15 +13,10 @@ package org.eclipse.cdt.internal.core.index.composite.cpp; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; -public class CompositeCPPConstructorSpecialization extends -CompositeCPPMethodSpecialization implements ICPPConstructor { +public class CompositeCPPConstructorSpecialization extends CompositeCPPMethodSpecialization implements + ICPPConstructor { public CompositeCPPConstructorSpecialization(ICompositesFactory cf, ICPPConstructor cons) { super(cf, cons); - } - - public boolean isExplicit() { - return ((ICPPConstructor)rbinding).isExplicit(); - } - + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorTemplate.java index 5822df52282..46a011bf422 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorTemplate.java @@ -18,9 +18,4 @@ public class CompositeCPPConstructorTemplate extends CompositeCPPMethodTemplate public CompositeCPPConstructorTemplate(ICompositesFactory cf, ICPPConstructor rbinding) { super(cf, rbinding); } - - public boolean isExplicit() { - return ((ICPPConstructor)rbinding).isExplicit(); - } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorTemplateSpecialization.java index d44b57cac2d..4c06fc10017 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPConstructorTemplateSpecialization.java @@ -22,8 +22,4 @@ public class CompositeCPPConstructorTemplateSpecialization ICPPFunction ft) { super(cf, ft); } - - public boolean isExplicit() { - return ((ICPPConstructor)rbinding).isExplicit(); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethod.java index 1ee3be9c688..d82a6f97d76 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethod.java @@ -30,6 +30,10 @@ class CompositeCPPMethod extends CompositeCPPFunction implements ICPPMethod { return ((ICPPMethod)rbinding).isImplicit(); } + public boolean isExplicit() { + return ((ICPPMethod)rbinding).isExplicit(); + } + public boolean isVirtual() { return ((ICPPMethod)rbinding).isVirtual(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodInstance.java index 38f093130f4..659385fc4f0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodInstance.java @@ -29,6 +29,10 @@ public class CompositeCPPMethodInstance extends CompositeCPPFunctionInstance imp return ((ICPPMethod)rbinding).isImplicit(); } + public boolean isExplicit() { + return ((ICPPMethod)rbinding).isExplicit(); + } + public boolean isVirtual() { return ((ICPPMethod)rbinding).isDestructor(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodSpecialization.java index 22805ab3521..167c2f57bd5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodSpecialization.java @@ -30,6 +30,10 @@ implements ICPPMethod { return ((ICPPMethod)rbinding).isImplicit(); } + public boolean isExplicit() { + return ((ICPPMethod)rbinding).isExplicit(); + } + public boolean isVirtual() { return ((ICPPMethod)rbinding).isVirtual(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodTemplate.java index 9341e51047e..42b11be3c7f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodTemplate.java @@ -29,6 +29,10 @@ public class CompositeCPPMethodTemplate extends CompositeCPPFunctionTemplate imp return ((ICPPMethod)rbinding).isImplicit(); } + public boolean isExplicit() { + return ((ICPPMethod)rbinding).isExplicit(); + } + public boolean isVirtual() { return ((ICPPMethod)rbinding).isVirtual(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodTemplateSpecialization.java index 999bfc871dc..e3803e49e73 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPMethodTemplateSpecialization.java @@ -33,6 +33,10 @@ public class CompositeCPPMethodTemplateSpecialization return ((ICPPMethod)rbinding).isImplicit(); } + public boolean isExplicit() { + return ((ICPPMethod)rbinding).isExplicit(); + } + public boolean isVirtual() { return ((ICPPMethod)rbinding).isVirtual(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotation.java index 3d599c671e6..40dde068aba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAnnotation.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; @@ -37,7 +36,7 @@ class PDOMCPPAnnotation { public static final int VIRTUAL_OFFSET = 0; public static final int DESTRUCTOR_OFFSET = 1; public static final int IMPLICIT_METHOD_OFFSET = 2; - public static final int EXPLICIT_CONSTRUCTOR_OFFSET = 3; + public static final int EXPLICIT_METHOD_OFFSET = 3; public static final int PURE_VIRTUAL_OFFSET = 4; public static final int MAX_EXTRA_OFFSET= PURE_VIRTUAL_OFFSET; @@ -92,12 +91,7 @@ class PDOMCPPAnnotation { modifiers |= (method.isDestructor() ? 1 : 0) << DESTRUCTOR_OFFSET; modifiers |= (method.isImplicit() ? 1 : 0) << IMPLICIT_METHOD_OFFSET; modifiers |= (method.isPureVirtual() ? 1 : 0) << PURE_VIRTUAL_OFFSET; - } - if (binding instanceof ICPPConstructor) { - ICPPConstructor constructor= (ICPPConstructor) binding; - if (constructor.isExplicit()) { - modifiers |= (1 << EXPLICIT_CONSTRUCTOR_OFFSET); - } + modifiers |= (method.isExplicit() ? 1 : 0) << EXPLICIT_METHOD_OFFSET; } return modifiers; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructor.java index ddd8db8fb6f..474861c62aa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructor.java @@ -29,10 +29,6 @@ class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor { super(linkage, record); } - public boolean isExplicit() { - return getBit(getAnnotation1(), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET); - } - @Override public int getNodeType() { return IIndexCPPBindingConstants.CPP_CONSTRUCTOR; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorInstance.java index 2759f273c66..87a18b70003 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorInstance.java @@ -49,8 +49,4 @@ public class PDOMCPPConstructorInstance extends PDOMCPPMethodInstance implements public int getNodeType() { return IIndexCPPBindingConstants.CPP_CONSTRUCTOR_INSTANCE; } - - public boolean isExplicit() { - return ((ICPPConstructor)getTemplateDefinition()).isExplicit(); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorSpecialization.java index 01cf06f8353..bfe54411b4d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorSpecialization.java @@ -47,8 +47,4 @@ class PDOMCPPConstructorSpecialization extends public int getNodeType() { return IIndexCPPBindingConstants.CPP_CONSTRUCTOR_SPECIALIZATION; } - - public boolean isExplicit() { - return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplate.java index 76c8c45c831..27e4d1febad 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplate.java @@ -32,10 +32,6 @@ class PDOMCPPConstructorTemplate extends PDOMCPPMethodTemplate implements public PDOMCPPConstructorTemplate(PDOMLinkage linkage, long record) { super(linkage, record); } - - public boolean isExplicit() { - return getBit(getAnnotation1(), PDOMCPPAnnotation.EXPLICIT_CONSTRUCTOR_OFFSET); - } @Override public int getNodeType() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplateSpecialization.java index 2155a317ad7..363ea3a958e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPConstructorTemplateSpecialization.java @@ -48,8 +48,4 @@ class PDOMCPPConstructorTemplateSpecialization extends public int getNodeType() { return IIndexCPPBindingConstants.CPP_CONSTRUCTOR_TEMPLATE_SPECIALIZATION; } - - public boolean isExplicit() { - return ((ICPPConstructor)getSpecializedBinding()).isExplicit(); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java index 8b6e95ecd4f..e63ff8664dd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java @@ -130,6 +130,10 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod { return getBit(getAnnotation1(), PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET); } + public boolean isExplicit() { + return getBit(getAnnotation1(), PDOMCPPAnnotation.EXPLICIT_METHOD_OFFSET); + } + @Override public IScope getFunctionScope() throws DOMException { throw new PDOMNotImplementedError(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodInstance.java index 95f32619c90..fe5f3c02950 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodInstance.java @@ -71,6 +71,10 @@ class PDOMCPPMethodInstance extends PDOMCPPFunctionInstance implements ICPPMetho return ((ICPPMethod)getTemplateDefinition()).isPureVirtual(); } + public boolean isExplicit() { + return ((ICPPMethod)getTemplateDefinition()).isExplicit(); + } + public ICPPClassType getClassOwner() { return (ICPPClassType) getOwner(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java index 797bccd6a47..e7c45b5cde5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java @@ -86,6 +86,10 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET); } + public boolean isExplicit() { + return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.EXPLICIT_METHOD_OFFSET); + } + public boolean isVirtual() { return getBit(getByte(record + ANNOTATION1), PDOMCPPAnnotation.VIRTUAL_OFFSET); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java index 599649a873b..9f368747ae6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplate.java @@ -93,6 +93,10 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho return getBit(getAnnotation1(), PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET); } + public boolean isExplicit() { + return getBit(getAnnotation1(), PDOMCPPAnnotation.EXPLICIT_METHOD_OFFSET); + } + public boolean isVirtual() { return getBit(getAnnotation1(), PDOMCPPAnnotation.VIRTUAL_OFFSET); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplateSpecialization.java index c9bcf33a9cd..1771a31ed99 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodTemplateSpecialization.java @@ -57,6 +57,14 @@ class PDOMCPPMethodTemplateSpecialization extends } return false; } + + public boolean isExplicit() { + IBinding spec = getSpecializedBinding(); + if (spec instanceof ICPPMethod) { + ((ICPPMethod)spec).isExplicit(); + } + return false; + } public boolean isVirtual() { IBinding spec = getSpecializedBinding(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java index 7b25a235150..33c8c084062 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java @@ -16,20 +16,20 @@ import java.net.URI; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.StyledString; -import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; import org.eclipse.search.ui.text.AbstractTextSearchResult; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; -import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider; +import org.eclipse.cdt.internal.core.dom.parser.ASTProblem; import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.internal.ui.CPluginImages; @@ -121,7 +121,7 @@ public class PDOMSearchLabelProvider extends LabelProvider implements IStyledLab } else if (element instanceof ProblemSearchElement) { ProblemSearchElement pse= (ProblemSearchElement) element; - return ASTSignatureUtil.getProblemMessage(pse.getProblemID(), pse.getDetail()); + return ASTProblem.getMessage(pse.getProblemID(), pse.getDetail()); } if (element instanceof IPath) {