From 8bc2a7437a355a4c3bc7fb825e1e29f794e04e16 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Thu, 27 Mar 2008 18:31:16 +0000 Subject: [PATCH] 222748: refactor semantic routines to separate package --- .../core/parser/tests/ast2/AST2BaseTest.java | 2 +- .../core/parser/tests/ast2/AST2CPPTests.java | 4 +- .../ast2/AST2SelectionParseBaseTest.java | 2 +- .../parser/tests/ast2/AST2SpecBaseTest.java | 2 +- .../parser/tests/ast2/AST2TemplateTests.java | 13 +- .../tests/ast2/CompleteParser2Tests.java | 2 +- .../parser/tests/ast2/QuickParser2Tests.java | 2 +- .../tests/IndexBindingResolutionTestBase.java | 2 +- .../tests/IndexCPPTemplateResolutionTest.java | 6 +- .../internal/pdom/tests/PDOMCBugsTest.java | 4 +- .../org.eclipse.cdt.core/META-INF/MANIFEST.MF | 1 + .../internal/core/model/CModelBuilder2.java | 2 +- .../org/eclipse/cdt/core/dom/IName.java | 1 + .../eclipse/cdt/core/dom/ast/ASTTypeUtil.java | 2 +- .../core/dom/parser/ISourceCodeParser.java | 1 + .../cpp/ICPPParserExtensionConfiguration.java | 1 + .../core/dom/parser/ProblemBinding.java | 2 +- .../core/dom/parser/c/CExternalFunction.java | 2 +- .../core/dom/parser/cpp/CPPASTAmbiguity.java | 1 + .../parser/cpp/CPPASTAmbiguousExpression.java | 1 + .../cpp/CPPASTArraySubscriptExpression.java | 1 + .../dom/parser/cpp/CPPASTBaseSpecifier.java | 1 + .../parser/cpp/CPPASTBinaryExpression.java | 1 + .../CPPASTCompoundStatementExpression.java | 1 + .../cpp/CPPASTConditionalExpression.java | 1 + .../parser/cpp/CPPASTDeleteExpression.java | 1 + .../dom/parser/cpp/CPPASTExpressionList.java | 1 + .../dom/parser/cpp/CPPASTFieldReference.java | 2 + .../cpp/CPPASTFunctionCallExpression.java | 1 + .../dom/parser/cpp/CPPASTIdExpression.java | 2 + .../parser/cpp/CPPASTLiteralExpression.java | 1 + .../core/dom/parser/cpp/CPPASTName.java | 2 + .../parser/cpp/CPPASTNamedTypeSpecifier.java | 1 + .../dom/parser/cpp/CPPASTNewExpression.java | 1 + .../dom/parser/cpp/CPPASTQualifiedName.java | 1 + ...CPPASTSimpleTypeConstructorExpression.java | 1 + .../core/dom/parser/cpp/CPPASTTemplateId.java | 1 + .../dom/parser/cpp/CPPASTTranslationUnit.java | 5 +- .../parser/cpp/CPPASTTypeIdExpression.java | 1 + .../parser/cpp/CPPASTTypenameExpression.java | 1 + .../dom/parser/cpp/CPPASTUnaryExpression.java | 1 + .../parser/cpp/CPPASTUsingDeclaration.java | 1 + .../dom/parser/cpp/CPPASTUsingDirective.java | 1 + .../core/dom/parser/cpp/CPPClassInstance.java | 5 +- .../core/dom/parser/cpp/CPPClassScope.java | 3 + .../parser/cpp/CPPClassSpecialization.java | 5 +- .../cpp/CPPClassSpecializationScope.java | 6 +- .../core/dom/parser/cpp/CPPClassTemplate.java | 1 + ...CPPClassTemplatePartialSpecialization.java | 1 + .../cpp/CPPClassTemplateSpecialization.java | 1 + .../core/dom/parser/cpp/CPPClassType.java | 1 + .../parser/cpp/CPPDeferredClassInstance.java | 1 + .../cpp/CPPDeferredFunctionInstance.java | 2 + .../core/dom/parser/cpp/CPPEnumeration.java | 1 + .../core/dom/parser/cpp/CPPEnumerator.java | 1 + .../parser/cpp/CPPFieldSpecialization.java | 1 + .../core/dom/parser/cpp/CPPFunction.java | 1 + .../dom/parser/cpp/CPPFunctionInstance.java | 1 + .../core/dom/parser/cpp/CPPFunctionScope.java | 1 + .../parser/cpp/CPPFunctionSpecialization.java | 2 + .../dom/parser/cpp/CPPFunctionTemplate.java | 1 + .../CPPFunctionTemplateSpecialization.java | 1 + .../dom/parser/cpp/CPPImplicitFunction.java | 1 + .../dom/parser/cpp/CPPImplicitMethod.java | 1 + .../core/dom/parser/cpp/CPPLabel.java | 1 + .../core/dom/parser/cpp/CPPMethod.java | 1 + .../dom/parser/cpp/CPPMethodTemplate.java | 1 + .../core/dom/parser/cpp/CPPNamespace.java | 1 + .../dom/parser/cpp/CPPNamespaceAlias.java | 1 + .../dom/parser/cpp/CPPNamespaceScope.java | 5 +- .../core/dom/parser/cpp/CPPParameter.java | 2 + .../cpp/CPPParameterSpecialization.java | 1 + .../core/dom/parser/cpp/CPPScope.java | 4 +- .../dom/parser/cpp/CPPSpecialization.java | 1 + .../dom/parser/cpp/CPPTemplateDefinition.java | 2 + .../cpp/CPPTemplateNonTypeParameter.java | 1 + .../dom/parser/cpp/CPPTemplateParameter.java | 1 + .../core/dom/parser/cpp/CPPTemplateScope.java | 2 + .../cpp/CPPTemplateTemplateParameter.java | 1 + .../parser/cpp/CPPTemplateTypeParameter.java | 1 + .../core/dom/parser/cpp/CPPTypedef.java | 1 + .../parser/cpp/CPPTypedefSpecialization.java | 1 + .../dom/parser/cpp/CPPUnknownBinding.java | 4 +- .../parser/cpp/CPPUnknownClassInstance.java | 1 + .../core/dom/parser/cpp/CPPUnknownScope.java | 1 + .../dom/parser/cpp/CPPUsingDeclaration.java | 1 + .../dom/parser/cpp/CPPUsingDirective.java | 1 + .../core/dom/parser/cpp/CPPVariable.java | 1 + .../core/dom/parser/cpp/ClassTypeMixin.java | 2 + .../cpp/{ => semantics}/CPPSemantics.java | 1127 +---------------- .../cpp/{ => semantics}/CPPTemplates.java | 41 +- .../cpp/{ => semantics}/CPPVisitor.java | 42 +- .../dom/parser/cpp/semantics/Conversions.java | 562 ++++++++ .../core/dom/parser/cpp/semantics/Cost.java | 155 +++ .../dom/parser/cpp/semantics/LookupData.java | 417 ++++++ .../parser/cpp/semantics/SemanticUtil.java | 96 ++ .../core/index/IndexCPPSignatureUtil.java | 2 +- .../composite/AbstractCompositeFactory.java | 2 +- .../cpp/CompositeCPPClassInstance.java | 2 +- .../cpp/CompositeCPPClassTemplate.java | 2 +- .../CompositeCPPDeferredClassInstance.java | 2 +- .../core/pdom/db/IBTreeComparator.java | 2 + .../internal/core/pdom/db/IBTreeVisitor.java | 2 + .../dom/PDOMFragmentBindingComparator.java | 2 +- .../pdom/dom/cpp/PDOMCPPClassInstance.java | 4 +- .../dom/cpp/PDOMCPPClassSpecialization.java | 7 +- .../pdom/dom/cpp/PDOMCPPClassTemplate.java | 4 +- ...CPPClassTemplatePartialSpecialization.java | 2 +- .../PDOMCPPClassTemplateSpecialization.java | 2 +- .../core/pdom/dom/cpp/PDOMCPPClassType.java | 2 +- .../dom/cpp/PDOMCPPDeferredClassInstance.java | 2 +- .../pdom/dom/cpp/PDOMCPPFunctionTemplate.java | 4 +- ...PDOMCPPFunctionTemplateSpecialization.java | 2 +- .../core/pdom/dom/cpp/PDOMCPPLinkage.java | 2 +- .../core/pdom/dom/cpp/PDOMCPPNamespace.java | 2 +- .../internal/ui/callhierarchy/CHQueries.java | 2 +- .../ui/refactoring/rename/ASTManager.java | 2 +- .../DOMCompletionProposalComputer.java | 2 +- .../DefaultCFoldingStructureProvider.java | 2 +- .../classwizard/NewClassWizardUtil.java | 2 +- 120 files changed, 1501 insertions(+), 1158 deletions(-) rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/{ => semantics}/CPPSemantics.java (70%) rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/{ => semantics}/CPPTemplates.java (95%) rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/{ => semantics}/CPPVisitor.java (96%) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Cost.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java index f13502d2adf..8fe5e590a73 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java @@ -66,8 +66,8 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor; 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 1c45cada70c..43187345274 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 @@ -105,9 +105,9 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerToMemberType; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.util.CharArrayUtils; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.parser.ParserException; /** diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java index 4d3ef2d8e4d..c0140d383a5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java @@ -32,8 +32,8 @@ import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.tests.FileBasePluginTest; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.core.resources.IFile; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java index 319b4b87541..eba35fa507e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java @@ -37,8 +37,8 @@ import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.parser.ParserException; /** diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index d9d265ab6e3..4c1be0d2ed1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType; + import java.util.Iterator; import junit.framework.TestSuite; @@ -60,8 +62,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.parser.ParserLanguage; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** * @author aniefer @@ -2125,7 +2126,7 @@ public class AST2TemplateTests extends AST2BaseTest { if ("r".equals(String.valueOf(name))) { IBinding b0 = name.resolveBinding(); IType type = ((ICPPVariable) b0).getType(); - type = CPPSemantics.getUltimateType(type, false); + type = getUltimateType(type, false); assertInstance(type, IBasicType.class); assertEquals("int", ASTTypeUtil.getType(type)); } @@ -2159,7 +2160,7 @@ public class AST2TemplateTests extends AST2BaseTest { if ("r".equals(String.valueOf(name))) { IBinding b0 = name.resolveBinding(); IType type = ((ICPPVariable) b0).getType(); - type = CPPSemantics.getUltimateType(type, false); + type = getUltimateType(type, false); assertInstance(type, IBasicType.class); assertEquals("int", ASTTypeUtil.getType(type)); } @@ -2199,7 +2200,7 @@ public class AST2TemplateTests extends AST2BaseTest { if ("r".equals(String.valueOf(name))) { IBinding b0 = name.resolveBinding(); IType type = ((ICPPVariable) b0).getType(); - type = CPPSemantics.getUltimateType(type, false); + type = getUltimateType(type, false); assertInstance(type, IBasicType.class); assertEquals("int", ASTTypeUtil.getType(type)); } @@ -2229,7 +2230,7 @@ public class AST2TemplateTests extends AST2BaseTest { if ("x".equals(String.valueOf(name))) { IBinding b0 = name.resolveBinding(); IType type = ((ICPPVariable) b0).getType(); - type = CPPSemantics.getUltimateType(type, false); + type = getUltimateType(type, false); assertInstance(type, IBasicType.class); assertEquals("int", ASTTypeUtil.getType(type)); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java index 76522b8da91..c354a3e4320 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java @@ -78,8 +78,8 @@ import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.core.runtime.Platform; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java index d4cc3a774e1..ea961c06286 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java @@ -34,8 +34,8 @@ import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.parser.ParserException; /** diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java index 1875fba33e3..39bee0e29fc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java @@ -37,7 +37,7 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; import org.eclipse.cdt.internal.pdom.tests.PDOMPrettyPrinter; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index dc4414f405e..57e17c8f555 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -42,7 +42,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.parser.util.ObjectMap; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; /** * Tests for exercising resolution of template bindings against IIndex @@ -874,7 +874,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa IBinding b0= getBindingFromASTName("r)", 1); assertInstance(b0, ICPPVariable.class); IType type = ((ICPPVariable) b0).getType(); - type = CPPSemantics.getUltimateType(type, false); + type = SemanticUtil.getUltimateType(type, false); assertInstance(type, IBasicType.class); assertEquals("int", ASTTypeUtil.getType(type)); } @@ -917,7 +917,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa ICPPTemplateInstance par2 = (ICPPTemplateInstance) argumentMap.getAt(1); // Allocator <> CPP_DEFERRED_CLASS_INSTANCE IType[] par2Arguments = par2.getArguments(); // [_Tp CPP_TEMPLATE_TYPE_PARAMETER] ObjectMap par2ArgumentMap = par2.getArgumentMap(); - type = CPPSemantics.getUltimateType(type, false); + type = SemanticUtil.getUltimateType(type, false); assertInstance(type, ICPPClassType.class); assertEquals("A", ((ICPPClassType) type).getName()); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java index 1b1696c7bf3..e2d00141903 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java @@ -30,7 +30,7 @@ import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.CCoreInternals; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -82,7 +82,7 @@ public class PDOMCBugsTest extends BaseTestCase { for(int i=0; i> usingDirectives= Collections.emptyMap(); - public ObjectSet visited= new ObjectSet(1); //used to ensure we don't visit things more than once - public ObjectSet inheritanceChain; //used to detect circular inheritance - public ObjectSet associated = ObjectSet.EMPTY_SET; - - public boolean checkWholeClassScope = false; - public boolean ignoreUsingDirectives = false; - public boolean usingDirectivesOnly = false; - public boolean forceQualified = false; - public boolean forUserDefinedConversion = false; - public boolean forAssociatedScopes = false; - public boolean contentAssist = false; - public boolean prefixLookup = false; - public boolean typesOnly = false; - public boolean considerConstructors = false; - public Object foundItems = null; - public Object [] functionParameters; - public IASTNode [] templateArguments; - public ProblemBinding problem; - - - public LookupData( IASTName n ){ - astName = n; - tu= (CPPASTTranslationUnit) astName.getTranslationUnit(); - typesOnly = typesOnly(); - considerConstructors = considerConstructors(); - checkWholeClassScope = checkWholeClassScope(); - } - public LookupData(){ - astName = null; - } - public final char [] name () { - if( astName != null ) - return astName.toCharArray(); - return EMPTY_NAME_ARRAY; - } - public boolean includeBlockItem( IASTNode item ){ - if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return true; - if( ( astName != null && astName.getParent() instanceof IASTIdExpression ) || - item instanceof ICPPASTNamespaceDefinition || - (item instanceof IASTSimpleDeclaration && ((IASTSimpleDeclaration)item).getDeclSpecifier() instanceof IASTCompositeTypeSpecifier ) || - item instanceof ICPPASTTemplateDeclaration ) - { - return true; - } - return false; - } - private boolean typesOnly(){ - if( astName == null ) return false; - if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return false; - IASTNode parent = astName.getParent(); - if( parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTElaboratedTypeSpecifier || - parent instanceof ICPPASTCompositeTypeSpecifier ) - return true; - if( parent instanceof ICPPASTQualifiedName ){ - IASTName [] ns = ((ICPPASTQualifiedName)parent).getNames(); - return ( astName != ns[ ns.length -1 ] ); - } - return false; - } - public boolean forUsingDeclaration(){ - if( astName == null ) return false; - if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return false; - IASTNode p1 = astName.getParent(); - if( p1 instanceof ICPPASTUsingDeclaration ) - return true; - - if( p1 instanceof ICPPASTQualifiedName ){ - IASTNode p2 = p1.getParent(); - if( p2 instanceof ICPPASTUsingDeclaration ){ - IASTName [] ns = ((ICPPASTQualifiedName) p1 ).getNames(); - return (ns[ ns.length - 1 ] == astName); - } - } - return false; - } - public boolean forDefinition(){ - if( astName == null ) return false; - if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return false; - - IASTName n = astName; - if( n.getParent() instanceof ICPPASTTemplateId ) - n = (IASTName) n.getParent(); - IASTNode p1 = n.getParent(); - if( p1 instanceof ICPPASTQualifiedName ){ - IASTName [] ns = ((ICPPASTQualifiedName)p1).getNames(); - if( ns[ns.length - 1] != n ) - return false; - p1 = p1.getParent(); - } - IASTNode p2 = p1.getParent(); - if( p1 instanceof IASTDeclarator && p2 instanceof IASTSimpleDeclaration ){ - return !( p2.getParent() instanceof ICPPASTExplicitTemplateInstantiation ); - } - return ( p1 instanceof IASTDeclarator && p2 instanceof IASTFunctionDefinition); - } - - public boolean forExplicitInstantiation(){ - if( astName == null ) return false; - if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return false; - - IASTName n = astName; - if( n.getParent() instanceof ICPPASTTemplateId ) - n = (IASTName) n.getParent(); - IASTNode p1 = n.getParent(); - if( p1 instanceof ICPPASTQualifiedName ){ - IASTName [] ns = ((ICPPASTQualifiedName)p1).getNames(); - if( ns[ns.length - 1] != n ) - return false; - p1 = p1.getParent(); - } - IASTNode p2 = p1.getParent(); - if( p1 instanceof IASTDeclarator && p2 instanceof IASTSimpleDeclaration ){ - return ( p2.getParent() instanceof ICPPASTExplicitTemplateInstantiation ); - } - return false; - } - - private boolean considerConstructors(){ - if( astName == null ) return false; - if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return false; - IASTNode p1 = astName.getParent(); - IASTNode p2 = p1.getParent(); - - if( p1 instanceof ICPPASTConstructorChainInitializer ) - return true; - if( p1 instanceof ICPPASTNamedTypeSpecifier && p2 instanceof IASTTypeId ) - return p2.getParent() instanceof ICPPASTNewExpression; - else if( p1 instanceof ICPPASTQualifiedName ){ - if( p2 instanceof ICPPASTFunctionDeclarator ){ - IASTName[] names = ((ICPPASTQualifiedName)p1).getNames(); - if( names.length >= 2 && names[ names.length - 1 ] == astName ) - return CPPVisitor.isConstructor( names[ names.length - 2 ], (IASTDeclarator) p2 ); - } else if( p2 instanceof ICPPASTNamedTypeSpecifier ){ - IASTNode p3 = p2.getParent(); - return p3 instanceof IASTTypeId && p3.getParent() instanceof ICPPASTNewExpression; - } else if( p2 instanceof IASTIdExpression ){ - return p2.getParent() instanceof IASTFunctionCallExpression; - } - } else if( p1 instanceof IASTFunctionCallExpression || p2 instanceof IASTFunctionCallExpression ) - return true; - return false; - } - public boolean qualified(){ - if( forceQualified ) return true; - if( astName == null ) return false; - if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return false; - IASTNode p1 = astName.getParent(); - if( p1 instanceof ICPPASTQualifiedName ){ - final IASTName[] qnames = ((ICPPASTQualifiedName)p1).getNames(); - return qnames.length == 1 || qnames[0] != astName; - } - return p1 instanceof ICPPASTFieldReference; - } - public boolean functionCall(){ - if( astName == null ) return false; - if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return false; - IASTNode p1 = astName.getParent(); - if( p1 instanceof ICPPASTQualifiedName ) - p1 = p1.getParent(); - return ( p1 instanceof IASTIdExpression && p1.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME ); - } - private boolean checkWholeClassScope() { - if( astName == null ) return false; - if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return true; - - IASTNode parent = astName.getParent(); - while( parent != null && !(parent instanceof IASTFunctionDefinition) ){ - parent = parent.getParent(); - } - if( parent instanceof IASTFunctionDefinition ){ - while( parent.getParent() instanceof ICPPASTTemplateDeclaration ) - parent = parent.getParent(); - if( parent.getPropertyInParent() != IASTCompositeTypeSpecifier.MEMBER_DECLARATION ) - return false; - - ASTNodeProperty prop = astName.getPropertyInParent(); - if( prop == ICPPASTQualifiedName.SEGMENT_NAME ) - prop = astName.getParent().getPropertyInParent(); - if( prop == IASTIdExpression.ID_NAME || - prop == IASTFieldReference.FIELD_NAME || - prop == ICASTFieldDesignator.FIELD_NAME || - prop == ICPPASTUsingDirective.QUALIFIED_NAME || - prop == ICPPASTUsingDeclaration.NAME || - prop == IASTFunctionCallExpression.FUNCTION_NAME || - prop == IASTNamedTypeSpecifier.NAME || - prop == ICPPASTConstructorChainInitializer.MEMBER_ID ) - { - return true; - } - } - return false; - } - - public boolean hasResults(){ - if( foundItems == null ) - return false; - if( foundItems instanceof Object [] ) - return ((Object[])foundItems).length != 0; - if( foundItems instanceof CharArrayObjectMap ) - return ((CharArrayObjectMap)foundItems).size() != 0; - return false; - } - /** - * an IType[] of function arguments, inluding the implied object argument - * @return - */ - public IType getImpliedObjectArgument() { - IType implied = null; - - if( astName != null ){ - IASTName tempName = astName; - while( tempName.getParent() instanceof IASTName ) - tempName = (IASTName) tempName.getParent(); - - ASTNodeProperty prop = tempName.getPropertyInParent(); - if( (prop == STRING_LOOKUP_PROPERTY && tempName.getParent() instanceof ICPPASTUnaryExpression) ) { - ICPPASTUnaryExpression unaryExp = (ICPPASTUnaryExpression) tempName.getParent(); - IASTExpression oprd= unaryExp.getOperand(); - return CPPVisitor.getExpressionType(oprd); - } else if( prop == IASTFieldReference.FIELD_NAME || - (prop == STRING_LOOKUP_PROPERTY && tempName.getParent() instanceof ICPPASTFieldReference) ) - { - ICPPASTFieldReference fieldRef = (ICPPASTFieldReference) tempName.getParent(); - implied = CPPVisitor.getExpressionType( fieldRef.getFieldOwner() ); - IType ultimateImplied= getUltimateTypeUptoPointers(implied); - if( prop != STRING_LOOKUP_PROPERTY && fieldRef.isPointerDereference() && ultimateImplied instanceof ICPPClassType) { - ICPPFunction operator= findOperator(fieldRef, (ICPPClassType) ultimateImplied); - try { - if(operator!=null) { - implied= operator.getType().getReturnType(); - } - } catch(DOMException de) { - return de.getProblem(); - } - } else if( fieldRef.isPointerDereference() && implied instanceof IPointerType ){ - try { - implied = ((IPointerType)implied).getType(); - } catch ( DOMException e ) { - implied = e.getProblem(); - } - } - } else if( prop == IASTIdExpression.ID_NAME ){ - IScope scope = CPPVisitor.getContainingScope( tempName ); - if( scope instanceof ICPPClassScope ){ - implied = ((ICPPClassScope)scope).getClassType(); - } else { - implied = CPPVisitor.getThisType( scope ); - if( implied instanceof IPointerType ){ - try { - implied = ((IPointerType)implied).getType(); - } catch ( DOMException e ) { - implied = e.getProblem(); - } - } - } - } else if( prop == STRING_LOOKUP_PROPERTY && tempName.getParent() instanceof IASTArraySubscriptExpression ){ - IASTExpression exp = ((IASTArraySubscriptExpression)tempName.getParent()).getArrayExpression(); - implied = CPPVisitor.getExpressionType( exp ); - } - } - return implied; - } - public boolean forFriendship() { - if( astName == null ) - return false; - IASTNode node = astName.getParent(); - while( node instanceof IASTName ) - node = node.getParent(); - - IASTDeclaration decl = null; - IASTDeclarator dtor = null; - if( node instanceof ICPPASTDeclSpecifier && node.getParent() instanceof IASTDeclaration ){ - decl = (IASTDeclaration) node.getParent(); - } else if( node instanceof IASTDeclarator ) { - dtor = (IASTDeclarator) node; - while( dtor.getParent() instanceof IASTDeclarator ) - dtor = (IASTDeclarator) dtor.getParent(); - if( !(dtor.getParent() instanceof IASTDeclaration) ) - return false; - decl = (IASTDeclaration) dtor.getParent(); - } else { - return false; - } - if( decl instanceof IASTSimpleDeclaration ){ - IASTSimpleDeclaration simple = (IASTSimpleDeclaration) decl; - if( ! ((ICPPASTDeclSpecifier)simple.getDeclSpecifier()).isFriend() ) - return false; - if( dtor != null ) - return true; - return simple.getDeclarators().length == 0; - } else if( decl instanceof IASTFunctionDefinition ){ - IASTFunctionDefinition fnDef = (IASTFunctionDefinition) decl; - if( ! ((ICPPASTDeclSpecifier)fnDef.getDeclSpecifier()).isFriend() ) - return false; - return ( dtor != null ); - } - return false; - } - - public boolean checkAssociatedScopes() { - if( astName == null || astName instanceof ICPPASTQualifiedName ) - return false; - IASTNode parent = astName.getParent(); - if( parent instanceof ICPPASTQualifiedName ){ - IASTName [] ns = ((ICPPASTQualifiedName)parent).getNames(); - if( ns[ ns.length - 1] != astName ) - return false; - } - return functionCall() && (associated.size() > 0); - } - public boolean checkClassContainingFriend() { - if( astName == null || astName instanceof ICPPASTQualifiedName ) - return false; - - IASTNode p = astName.getParent(); - ASTNodeProperty prop = null; - while( p != null ){ - prop = p.getPropertyInParent(); - if( prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT || prop == IASTDeclarator.DECLARATOR_NAME ) - return false; - if( p instanceof IASTDeclarator && !(((IASTDeclarator)p).getName() instanceof ICPPASTQualifiedName) ) - return false; - if( p instanceof IASTDeclaration ){ - if( prop == IASTCompositeTypeSpecifier.MEMBER_DECLARATION ){ - if( p instanceof IASTSimpleDeclaration ){ - ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)p).getDeclSpecifier(); - return declSpec.isFriend(); - } else if( p instanceof IASTFunctionDefinition ){ - ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)p).getDeclSpecifier(); - return declSpec.isFriend(); - } - } else { - return false; - } - } - p = p.getParent(); - } - return false; - } - public boolean preferTemplateFunctions() { - if( astName == null ) - return false; - return (astName instanceof ICPPASTTemplateId || astName.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME ); - } - } - - static protected class Cost { - //Some constants to help clarify things - public static final int AMBIGUOUS_USERDEFINED_CONVERSION = 1; - - public static final int NO_MATCH_RANK = -1; - public static final int IDENTITY_RANK = 0; - public static final int LVALUE_OR_QUALIFICATION_RANK = 0; - public static final int PROMOTION_RANK = 1; - public static final int CONVERSION_RANK = 2; - public static final int DERIVED_TO_BASE_CONVERSION = 3; - public static final int USERDEFINED_CONVERSION_RANK = 4; - public static final int ELLIPSIS_CONVERSION = 5; - public static final int FUZZY_TEMPLATE_PARAMETERS = 6; - - public IType source; - public IType target; - - public boolean targetHadReference = false; - - public int lvalue; - public int promotion; - public int conversion; - public int qualification; - public int userDefined; - public int rank = -1; - public int detail; - - public Cost( IType s, IType t ){ - source = s; - target = t; - } - - public int compare( Cost cost ) throws DOMException{ - int result = 0; - - if( rank != cost.rank ){ - return cost.rank - rank; - } - - if( userDefined != 0 || cost.userDefined != 0 ){ - if( userDefined == 0 || cost.userDefined == 0 ){ - return cost.userDefined - userDefined; - } - if( (userDefined == AMBIGUOUS_USERDEFINED_CONVERSION || cost.userDefined == AMBIGUOUS_USERDEFINED_CONVERSION) || - (userDefined != cost.userDefined ) ) - return 0; - - // else they are the same constructor/conversion operator and are ranked - //on the standard conversion sequence - - } - - if( promotion > 0 || cost.promotion > 0 ){ - result = cost.promotion - promotion; - } - if( conversion > 0 || cost.conversion > 0 ){ - if( detail == cost.detail ){ - result = cost.conversion - conversion; - } else { - result = cost.detail - detail; - } - } - - if( result == 0 ){ - if( cost.qualification != qualification ){ - return cost.qualification - qualification; - } else if( (cost.qualification == qualification) && qualification == 0 ){ - return 0; - } else { - IPointerType op1, op2; - IType t1 = cost.target, t2 = target; - int subOrSuper = 0; - while( true ){ - op1 = null; - op2 = null; - while( true ){ - if( t1 instanceof ITypedef ) - try { - t1 = ((ITypedef)t1).getType(); - } catch ( DOMException e ) { - t1 = e.getProblem(); - } - else { - if( t1 instanceof IPointerType ) - op1 = (IPointerType) t1; - break; - } - } - while( true ){ - if( t2 instanceof ITypedef ) - try { - t2 = ((ITypedef)t2).getType(); - } catch ( DOMException e ) { - t2 = e.getProblem(); - } - else { - if( t2 instanceof IPointerType ) - op1 = (IPointerType) t2; - break; - } - } - if( op1 == null || op2 == null ) - break; - - int cmp = ( op1.isConst() ? 1 : 0 ) + ( op1.isVolatile() ? 1 : 0 ) - - ( op2.isConst() ? 1 : 0 ) + ( op2.isVolatile() ? 1 : 0 ); - - if( subOrSuper == 0 ) - subOrSuper = cmp; - else if( subOrSuper > 0 ^ cmp > 0) { - result = -1; - break; - } - - } - if( result == -1 ){ - result = 0; - } else { - if( op1 == op2 ){ - result = subOrSuper; - } else { - result = op1 != null ? 1 : -1; - } - } - } - } - - return result; - } - } - static protected IBinding resolveBinding( IASTName name ){ //1: get some context info off of the name to figure out what kind of lookup we want LookupData data = createLookupData( name, true ); @@ -789,8 +309,8 @@ public class CPPSemantics { return binding; } - static private CPPSemantics.LookupData createLookupData( IASTName name, boolean considerAssociatedScopes ){ - CPPSemantics.LookupData data = new CPPSemantics.LookupData( name ); + static private LookupData createLookupData( IASTName name, boolean considerAssociatedScopes ){ + LookupData data = new LookupData( name ); IASTNode parent = name.getParent(); if( name instanceof ICPPASTTemplateId ){ @@ -1016,7 +536,7 @@ public class CPPSemantics { return resultMap; } - static protected void lookup( CPPSemantics.LookupData data, Object start ) throws DOMException{ + static protected void lookup( LookupData data, Object start ) throws DOMException{ IASTNode node = data.astName; IIndexFileSet fileSet= IIndexFileSet.EMPTY; @@ -1186,7 +706,7 @@ public class CPPSemantics { return parentScope; } - private static Object lookupInParents( CPPSemantics.LookupData data, ICPPScope lookIn ) throws DOMException{ + private static Object lookupInParents( LookupData data, ICPPScope lookIn ) throws DOMException{ ICPPBase [] bases = null; if( lookIn instanceof ICPPClassScope ){ ICPPClassType c = ((ICPPClassScope)lookIn).getClassType(); @@ -1387,7 +907,7 @@ public class CPPSemantics { * In case of an unqualified lookup the transitive directives are stored, also. This is important because * the members nominated by a transitive directive can appear before those of the original directive. */ - static private void storeUsingDirective(CPPSemantics.LookupData data, ICPPNamespaceScope container, + static private void storeUsingDirective(LookupData data, ICPPNamespaceScope container, ICPPUsingDirective directive, Set handled) throws DOMException { ICPPNamespaceScope nominated= directive.getNominatedScope(); if (nominated instanceof IIndexScope && data.tu != null) { @@ -1444,11 +964,16 @@ public class CPPSemantics { /** * + * @param data may be null to use a fresh LookupData * @param scope + * @param blockItem * @return List of encountered using directives * @throws DOMException */ - static protected IASTName[] lookupInScope( CPPSemantics.LookupData data, ICPPScope scope, IASTNode blockItem ) throws DOMException { + public static IASTName[] lookupInScope( LookupData data, ICPPScope scope, IASTNode blockItem ) throws DOMException { + if(data == null) { + data = new LookupData(); + } final boolean isIndexBased= data.tu == null ? false : data.tu.getIndex() != null; Object possible = null; IASTNode [] nodes = null; @@ -1630,7 +1155,7 @@ public class CPPSemantics { * that transitive directives have been stored in the lookup-data. For qualified lookups the transitive directives * are considered if the lookup of the original directive returns empty. */ - static private void lookupInNominated(CPPSemantics.LookupData data, ICPPNamespaceScope scope) throws DOMException{ + static private void lookupInNominated(LookupData data, ICPPNamespaceScope scope) throws DOMException{ List allNominated= data.usingDirectives.remove(scope); while (allNominated != null) { for (ICPPNamespaceScope nominated : allNominated) { @@ -1673,7 +1198,7 @@ public class CPPSemantics { } } - static private Object collectResult( CPPSemantics.LookupData data, ICPPScope scope, IASTNode node, boolean checkAux ) throws DOMException{ + static private Object collectResult( LookupData data, ICPPScope scope, IASTNode node, boolean checkAux ) throws DOMException{ IASTName resultName = null; IASTName [] resultArray = null; @@ -2011,7 +1536,7 @@ public class CPPSemantics { return ( pointOfDecl < pointOfRef ); } - static private IBinding resolveAmbiguities( CPPSemantics.LookupData data, IASTName name ) throws DOMException { + static private IBinding resolveAmbiguities( LookupData data, IASTName name ) throws DOMException { if( !data.hasResults() || data.contentAssist ) return null; @@ -2334,7 +1859,7 @@ public class CPPSemantics { return result; } - static private IBinding resolveFunction( CPPSemantics.LookupData data, IBinding[] fns ) throws DOMException{ + static IBinding resolveFunction( LookupData data, IBinding[] fns ) throws DOMException{ fns = (IBinding[]) ArrayUtil.trim( IBinding.class, fns ); if( fns == null || fns.length == 0 ) return null; @@ -2430,12 +1955,12 @@ public class CPPSemantics { cost = new Cost( source, target ); cost.rank = Cost.IDENTITY_RANK; //exact match, no cost } else { - cost = checkStandardConversionSequence( source, target, isImpliedObject); + cost = Conversions.checkStandardConversionSequence( source, target, isImpliedObject); //12.3-4 At most one user-defined conversion is implicitly applied to //a single value. (also prevents infinite loop) if (!data.forUserDefinedConversion && (cost.rank == Cost.NO_MATCH_RANK || cost.rank == Cost.FUZZY_TEMPLATE_PARAMETERS)) { - temp = checkUserDefinedConversionSequence( source, target ); + temp = Conversions.checkUserDefinedConversionSequence( source, target ); if( temp != null ){ cost = temp; } @@ -2764,581 +2289,7 @@ public class CPPSemantics { } return result; } - /** - * Computes the cost of using the standard conversion sequence from source to target. - * @param ignoreDerivedToBaseConversion 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 - */ - static protected Cost checkStandardConversionSequence( IType source, IType target, boolean isImplicitThis) throws DOMException { - Cost cost = lvalue_to_rvalue( source, target ); - - if( cost.source == null || cost.target == null ){ - return cost; - } - - if (cost.source.isSameType(cost.target) || - // 7.3.3.13 for overload resolution the implicit this pointer is treated as if - // it were a pointer to the derived class - (isImplicitThis && cost.source instanceof ICPPClassType && cost.target instanceof ICPPClassType)) { - cost.rank = Cost.IDENTITY_RANK; - return cost; - } - - qualificationConversion( cost ); - - //if we can't convert the qualifications, then we can't do anything - if( cost.qualification == Cost.NO_MATCH_RANK ){ - return cost; - } - - //was the qualification conversion enough? - IType s = getUltimateType( cost.source, true ); - IType t = getUltimateType( cost.target, true ); - - if( s == null || t == null ){ - cost.rank = Cost.NO_MATCH_RANK; - return cost; - } - - if (s.isSameType(t) || - // 7.3.3.13 for overload resolution the implicit this pointer is treated as if - // it were a pointer to the derived class - (isImplicitThis && s instanceof ICPPClassType && t instanceof ICPPClassType)) { - return cost; - } - - promotion( cost ); - if( cost.promotion > 0 || cost.rank > -1 ){ - return cost; - } - - conversion( cost ); - - if( cost.rank > -1 ) - return cost; - - derivedToBaseConversion( cost ); - - if( cost.rank == -1 ){ - relaxTemplateParameters( cost ); - } - return cost; - } - - static private Cost checkUserDefinedConversionSequence( IType source, IType target ) throws DOMException { - Cost cost = null; - Cost constructorCost = null; - Cost conversionCost = null; - - IType s = getUltimateType( source, true ); - IType t = getUltimateType( target, true ); - - ICPPConstructor constructor = null; - ICPPMethod conversion = null; - - //constructors - if( t instanceof ICPPClassType ){ - ICPPConstructor [] constructors = ((ICPPClassType)t).getConstructors(); - if( constructors.length > 0 ){ - if( constructors.length == 1 && constructors[0] instanceof IProblemBinding ) - constructor = null; - else { - LookupData data = new LookupData(); - data.forUserDefinedConversion = true; - data.functionParameters = new IType [] { source }; - IBinding binding = resolveFunction( data, constructors ); - if( binding instanceof ICPPConstructor ) - constructor = (ICPPConstructor) binding; - } - } - if( constructor != null && !constructor.isExplicit() ){ - constructorCost = checkStandardConversionSequence( t, target, false ); - } - } - - //conversion operators - if( s instanceof ICPPInternalClassType ){ - ICPPMethod [] ops = ((ICPPInternalClassType)s).getConversionOperators(); - if( ops.length > 0 && !(ops[0] instanceof IProblemBinding) ){ - Cost [] costs = null; - for (int i = 0; i < ops.length; i++) { - cost = checkStandardConversionSequence( ops[i].getType().getReturnType(), target, false ); - if( cost.rank != Cost.NO_MATCH_RANK ) - costs = (Cost[]) ArrayUtil.append( Cost.class, costs, cost ); - } - if( costs != null ){ - Cost best = costs[0]; - boolean bestIsBest = true; - int bestIdx = 0; - for (int i = 1; i < costs.length && costs[i] != null; i++) { - int comp = best.compare( costs[i] ); - if( comp == 0 ) - bestIsBest = false; - else if( comp > 0 ){ - best = costs[ bestIdx = i ]; - bestIsBest = true; - } - } - if( bestIsBest ){ - conversion = ops[ bestIdx ]; - conversionCost = best; - } - } - } - } - - //if both are valid, then the conversion is ambiguous - if( constructorCost != null && constructorCost.rank != Cost.NO_MATCH_RANK && - conversionCost != null && conversionCost.rank != Cost.NO_MATCH_RANK ) - { - cost = constructorCost; - cost.userDefined = Cost.AMBIGUOUS_USERDEFINED_CONVERSION; - cost.rank = Cost.USERDEFINED_CONVERSION_RANK; - } else { - if( constructorCost != null && constructorCost.rank != Cost.NO_MATCH_RANK ){ - cost = constructorCost; - cost.userDefined = constructor.hashCode(); - cost.rank = Cost.USERDEFINED_CONVERSION_RANK; - } else if( conversionCost != null && conversionCost.rank != Cost.NO_MATCH_RANK ){ - cost = conversionCost; - cost.userDefined = conversion.hashCode(); - cost.rank = Cost.USERDEFINED_CONVERSION_RANK; - } - } - return cost; - } - - /** - * Unravels a type by following purely typedefs - * @param type - * @return - */ - private static IType getUltimateTypeViaTypedefs(IType type) { - try { - while(type instanceof ITypedef) { - type= ((ITypedef)type).getType(); - } - } catch(DOMException e) { - type= e.getProblem(); - } - return type; - } - - private static IType getUltimateType(IType type, IType[] lastPointerType, boolean stopAtPointerToMember) { - try { - while( true ){ - if( type instanceof ITypedef ) - type= ((ITypedef)type).getType(); - else if( type instanceof IQualifierType ) - type= ((IQualifierType)type).getType(); - else if( stopAtPointerToMember && type instanceof ICPPPointerToMemberType ) - return type; - else if( type instanceof IPointerType ) { - if(lastPointerType!=null) { - lastPointerType[0]= type; - } - type= ((IPointerType) type).getType(); - } else if( type instanceof ICPPReferenceType ) - type= ((ICPPReferenceType)type).getType(); - else - return type; - - } - } catch ( DOMException e ) { - return e.getProblem(); - } - } - - public static IType getUltimateType(IType type, boolean stopAtPointerToMember) { - return getUltimateType(type, null, stopAtPointerToMember); - } - - /** - * Descends into type containers, stopping at pointer or - * pointer-to-member types. - * @param type - * @return the ultimate type contained inside the specified type - */ - public static IType getUltimateTypeUptoPointers(IType type){ - try { - while( true ){ - if( type instanceof ITypedef ) - type = ((ITypedef)type).getType(); - else if( type instanceof IQualifierType ) - type = ((IQualifierType)type).getType(); - else if( type instanceof ICPPReferenceType ) - type = ((ICPPReferenceType)type).getType(); - else - return type; - } - } catch ( DOMException e ) { - return e.getProblem(); - } - } - - static private boolean isCompleteType( IType type ){ - type = getUltimateType( type, false ); - if( type instanceof ICPPClassType && type instanceof ICPPInternalBinding ) - return (((ICPPInternalBinding)type).getDefinition() != null ); - return true; - } - static private Cost lvalue_to_rvalue( IType source, IType target ) throws DOMException{ - Cost cost = new Cost( source, target ); - - if( ! isCompleteType( source ) ){ - cost.rank = Cost.NO_MATCH_RANK; - return cost; - } - - if( source instanceof ICPPReferenceType ){ - source = ((ICPPReferenceType) source).getType(); - } - if( target instanceof ICPPReferenceType ){ - target = ((ICPPReferenceType) target).getType(); - cost.targetHadReference = true; - } - - //4.3 function to pointer conversion - if( target instanceof IPointerType && ((IPointerType)target).getType() instanceof IFunctionType && - source instanceof IFunctionType ) - { - source = new CPPPointerType( source ); - } - //4.2 Array-To-Pointer conversion - else if( target instanceof IPointerType && source instanceof IArrayType ){ - source = new CPPPointerType( ((IArrayType)source).getType() ); - } - - //4.1 if T is a non-class type, the type of the rvalue is the cv-unqualified version of T - if( source instanceof IQualifierType ){ - IType t = ((IQualifierType)source).getType(); - while( t instanceof ITypedef ) - t = ((ITypedef)t).getType(); - if( !(t instanceof ICPPClassType) ){ - source = t; - } - } else if( source instanceof IPointerType && - ( ((IPointerType)source).isConst() || ((IPointerType)source).isVolatile() ) ) - { - IType t = ((IPointerType)source).getType(); - while( t instanceof ITypedef ) - t = ((ITypedef)t).getType(); - if( !(t instanceof ICPPClassType) ){ - source = new CPPPointerType( t ); - } - } - - cost.source = source; - cost.target = target; - - return cost; - } - - static private void qualificationConversion( Cost cost ) throws DOMException{ - boolean canConvert = true; - int requiredConversion = Cost.IDENTITY_RANK; - - IType s = cost.source, t = cost.target; - boolean constInEveryCV2k = true; - boolean firstPointer= true; - while( true ){ - s= getUltimateTypeViaTypedefs(s); - t= getUltimateTypeViaTypedefs(t); - IPointerType op1= s instanceof IPointerType ? (IPointerType) s : null; - IPointerType op2= t instanceof IPointerType ? (IPointerType) t : null; - - if( op1 == null && op2 == null ) - break; - else if( op1 == null ^ op2 == null) { - // 4.12 - pointer types can be converted to bool - if(t instanceof ICPPBasicType) { - if(((ICPPBasicType)t).getType() == ICPPBasicType.t_bool) { - canConvert= true; - requiredConversion = Cost.CONVERSION_RANK; - break; - } - } - canConvert = false; - break; - } else if( op1 instanceof ICPPPointerToMemberType ^ op2 instanceof ICPPPointerToMemberType ){ - canConvert = false; - break; - } - - //if const is in cv1,j then const is in cv2,j. Similary for volatile - if( ( op1.isConst() && !op2.isConst() ) || ( op1.isVolatile() && !op2.isVolatile() ) ) { - canConvert = false; - requiredConversion = Cost.NO_MATCH_RANK; - break; - } - //if cv1,j and cv2,j are different then const is in every cv2,k for 0 0 ) ? Cost.PROMOTION_RANK : Cost.NO_MATCH_RANK; - } - - static private void conversion( Cost cost ) throws DOMException{ - IType src = cost.source; - IType trg = cost.target; - - cost.conversion = 0; - cost.detail = 0; - - IType[] sHolder= new IType[1], tHolder= new IType[1]; - IType s = getUltimateType( src, sHolder, true ); - IType t = getUltimateType( trg, tHolder, true ); - IType sPrev= sHolder[0], tPrev= tHolder[0]; - - if( src instanceof IBasicType && trg instanceof IPointerType ){ - //4.10-1 an integral constant expression of integer type that evaluates to 0 can be converted to a pointer type - IASTExpression exp = ((IBasicType)src).getValue(); - if( exp instanceof IASTLiteralExpression && - ((IASTLiteralExpression)exp).getKind() == IASTLiteralExpression.lk_integer_constant ) - { - try { - String val = exp.toString().toLowerCase().replace('u', '0'); - val.replace( 'l', '0' ); - if( Integer.decode( val ).intValue() == 0 ){ - cost.rank = Cost.CONVERSION_RANK; - cost.conversion = 1; - } - } catch( NumberFormatException e ) { - } - } - } else if( sPrev instanceof IPointerType ){ - //4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be - //converted to an rvalue of type "pointer to cv void" - if( tPrev instanceof IPointerType && t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void ){ - cost.rank = Cost.CONVERSION_RANK; - cost.conversion = 1; - cost.detail = 2; - return; - } - //4.10-3 An rvalue of type "pointer to cv D", where D is a class type can be converted - //to an rvalue of type "pointer to cv B", where B is a base class of D. - else if( s instanceof ICPPClassType && tPrev instanceof IPointerType && t instanceof ICPPClassType ){ - int depth= calculateInheritanceDepth( (ICPPClassType)s, (ICPPClassType) t ); - cost.rank= ( depth > -1 ) ? Cost.CONVERSION_RANK : Cost.NO_MATCH_RANK; - cost.conversion= ( depth > -1 ) ? depth : 0; - cost.detail= 1; - return; - } - // 4.12 if the target is a bool, we can still convert - else if(!(trg instanceof IBasicType && ((IBasicType)trg).getType() == ICPPBasicType.t_bool)) { - return; - } - } - - if( t instanceof IBasicType && s instanceof IBasicType || s instanceof IEnumeration ){ - //4.7 An rvalue of an integer type can be converted to an rvalue of another integer type. - //An rvalue of an enumeration type can be converted to an rvalue of an integer type. - cost.rank = Cost.CONVERSION_RANK; - cost.conversion = 1; - } else if( trg instanceof IBasicType && ((IBasicType)trg).getType() == ICPPBasicType.t_bool && s instanceof IPointerType ){ - //4.12 pointer or pointer to member type can be converted to an rvalue of type bool - cost.rank = Cost.CONVERSION_RANK; - cost.conversion = 1; - } else if( s instanceof ICPPPointerToMemberType && t instanceof ICPPPointerToMemberType ){ - //4.11-2 An rvalue of type "pointer to member of B of type cv T", where B is a class type, - //can be converted to an rvalue of type "pointer to member of D of type cv T" where D is a - //derived class of B - ICPPPointerToMemberType spm = (ICPPPointerToMemberType) s; - ICPPPointerToMemberType tpm = (ICPPPointerToMemberType) t; - IType st = spm.getType(); - IType tt = tpm.getType(); - if( st != null && tt != null && st.isSameType( tt ) ){ - int depth= calculateInheritanceDepth( tpm.getMemberOfClass(), spm.getMemberOfClass() ); - cost.rank= ( depth > -1 ) ? Cost.CONVERSION_RANK : Cost.NO_MATCH_RANK; - cost.conversion= ( depth > -1 ) ? depth : 0; - cost.detail= 1; - } - } - } - - static private void derivedToBaseConversion( Cost cost ) throws DOMException { - IType s = getUltimateType( cost.source, true ); - IType t = getUltimateType( cost.target, true ); - - if( cost.targetHadReference && s instanceof ICPPClassType && t instanceof ICPPClassType ){ - int depth= calculateInheritanceDepth( (ICPPClassType) s, (ICPPClassType) t ); - if(depth > -1){ - cost.rank= Cost.DERIVED_TO_BASE_CONVERSION; - cost.conversion= depth; - } - } - } - - static private void relaxTemplateParameters( Cost cost ){ - IType s = getUltimateType( cost.source, false ); - IType t = getUltimateType( cost.target, false ); - - if( (s instanceof ICPPTemplateTypeParameter && t instanceof ICPPTemplateTypeParameter) || - (s instanceof ICPPTemplateTemplateParameter && t instanceof ICPPTemplateTemplateParameter ) ) - { - cost.rank = Cost.FUZZY_TEMPLATE_PARAMETERS; - } - } - - /** - * Calculates the number of edges in the inheritance path of clazz to - * ancestorToFind, returning -1 if no inheritance relationship is found. - * @param clazz the class to search upwards from - * @param ancestorToFind the class to find in the inheritance graph - * @return the number of edges in the inheritance graph, or -1 if the specifide classes have - * no inheritance relation - * @throws DOMException - */ - private static int calculateInheritanceDepth(ICPPClassType clazz, ICPPClassType ancestorToFind) throws DOMException { - if(clazz == ancestorToFind || clazz.isSameType(ancestorToFind)) - return 0; - - ICPPBase [] bases = clazz.getBases(); - for(int i=0; i0) - return n+1; - } - } - } - - return -1; - } - - - public static ICPPFunction findOperator( IASTExpression exp, ICPPClassType cls ){ + public static ICPPFunction findOperator( IASTExpression exp, ICPPClassType cls ){ IScope scope = null; try { scope = cls.getCompositeScope(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java similarity index 95% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index b7335ea52ce..87913664cc3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -11,7 +11,7 @@ * 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.semantics; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; @@ -82,7 +82,36 @@ import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectSet; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.Cost; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstance; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplatePartialSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplateSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorInstance; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorTemplateSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFieldSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionTemplate; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionTemplateSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodInstance; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodTemplateSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameter; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTemplateParameter; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedefSpecialization; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBase; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassTemplate; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalDeferredClassInstance; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplate; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown; /** * @author aniefer @@ -399,7 +428,7 @@ public class CPPTemplates { } protected static IBinding createFunctionSpecialization(IASTName name) { - CPPSemantics.LookupData data = new CPPSemantics.LookupData(name); + LookupData data = new LookupData(name); data.forceQualified = true; ICPPScope scope = (ICPPScope) CPPVisitor.getContainingScope(name); if (scope instanceof ICPPTemplateScope) { @@ -1538,7 +1567,7 @@ public class CPPTemplates { pType = e.getProblem(); } } - Cost cost = CPPSemantics.checkStandardConversionSequence(argument, pType, false); + Cost cost = Conversions.checkStandardConversionSequence(argument, pType, false); if (cost == null || cost.rank == Cost.NO_MATCH_RANK) { return false; @@ -1575,7 +1604,7 @@ public class CPPTemplates { public static boolean typeContainsTemplateParameter(IType t) { if (t instanceof ICPPTemplateParameter) return true; - t = CPPSemantics.getUltimateType(t, false); + t = SemanticUtil.getUltimateType(t, false); return (t instanceof ICPPTemplateParameter); } @@ -1703,7 +1732,7 @@ public class CPPTemplates { IBinding origClass = origBase.getBaseClass(); if (origClass instanceof IType) { IType specClass = CPPTemplates.instantiateType((IType) origClass, classInstance.getArgumentMap()); - specClass = CPPSemantics.getUltimateType(specClass, true); + specClass = SemanticUtil.getUltimateType(specClass, true); if (specClass instanceof IBinding) { ((ICPPInternalBase) specBase).setBaseClass((IBinding) specClass); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java similarity index 96% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index f4aed3c18e0..cdc04f4ca73 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -10,7 +10,10 @@ * Markus Schorn (Wind River Systems) * Andrew Ferguson (Symbian) *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.parser.cpp; +package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; + +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers; import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; @@ -142,6 +145,39 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId; +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.CPPClassTemplate; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorTemplate; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumeration; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumerator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPField; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionTemplate; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPLabel; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodTemplate; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNamespace; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNamespaceAlias; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameter; +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.CPPQualifierType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScope; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedef; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable; +import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPBasicType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerToMemberType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown; import org.eclipse.cdt.internal.core.index.IIndexScope; /** @@ -900,7 +936,7 @@ public class CPPVisitor { IASTExpression owner = fieldReference.getFieldOwner(); IType type = getExpressionType(owner); if (fieldReference.isPointerDereference()) { - type= CPPSemantics.getUltimateTypeUptoPointers(type); + type= getUltimateTypeUptoPointers(type); if (type instanceof ICPPClassType) { ICPPFunction op = CPPSemantics.findOperator(fieldReference, (ICPPClassType) type); if (op != null) { @@ -908,7 +944,7 @@ public class CPPVisitor { } } } - type = CPPSemantics.getUltimateType(type, false); + type = getUltimateType(type, false); if (type instanceof ICPPClassType) { return ((ICPPClassType) type).getCompositeScope(); } 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 new file mode 100644 index 00000000000..4b4022b96de --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java @@ -0,0 +1,562 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Bryan Wilkinson (QNX) + * Andrew Ferguson (Symbian) + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; + +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeViaTypedefs; + +import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; +import org.eclipse.cdt.core.dom.ast.IArrayType; +import org.eclipse.cdt.core.dom.ast.IBasicType; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IEnumeration; +import org.eclipse.cdt.core.dom.ast.IFunctionType; +import org.eclipse.cdt.core.dom.ast.IPointerType; +import org.eclipse.cdt.core.dom.ast.IProblemBinding; +import org.eclipse.cdt.core.dom.ast.IQualifierType; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; +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.ICPPSpecialization; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; +import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassType; + +/** + * Routines for calculating the cost of conversions + * + * See + * [conv] 4 + * [over.best.ics] 13.3.3.1. + */ +class Conversions { + + /** + * Computes the cost of using the standard conversion sequence from source to target. + * @param ignoreDerivedToBaseConversion 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 + */ + static protected Cost checkStandardConversionSequence( IType source, IType target, boolean isImplicitThis) throws DOMException { + Cost cost = lvalue_to_rvalue( source, target ); + + if( cost.source == null || cost.target == null ){ + return cost; + } + + if (cost.source.isSameType(cost.target) || + // 7.3.3.13 for overload resolution the implicit this pointer is treated as if + // it were a pointer to the derived class + (isImplicitThis && cost.source instanceof ICPPClassType && cost.target instanceof ICPPClassType)) { + cost.rank = Cost.IDENTITY_RANK; + return cost; + } + + qualificationConversion( cost ); + + //if we can't convert the qualifications, then we can't do anything + if( cost.qualification == Cost.NO_MATCH_RANK ){ + return cost; + } + + //was the qualification conversion enough? + IType s = getUltimateType( cost.source, true ); + IType t = getUltimateType( cost.target, true ); + + if( s == null || t == null ){ + cost.rank = Cost.NO_MATCH_RANK; + return cost; + } + + if (s.isSameType(t) || + // 7.3.3.13 for overload resolution the implicit this pointer is treated as if + // it were a pointer to the derived class + (isImplicitThis && s instanceof ICPPClassType && t instanceof ICPPClassType)) { + return cost; + } + + promotion( cost ); + if( cost.promotion > 0 || cost.rank > -1 ){ + return cost; + } + + conversion( cost ); + + if( cost.rank > -1 ) + return cost; + + derivedToBaseConversion( cost ); + + if( cost.rank == -1 ){ + relaxTemplateParameters( cost ); + } + return cost; + } + + static Cost checkUserDefinedConversionSequence( IType source, IType target ) throws DOMException { + Cost cost = null; + Cost constructorCost = null; + Cost conversionCost = null; + + IType s = getUltimateType( source, true ); + IType t = getUltimateType( target, true ); + + ICPPConstructor constructor = null; + ICPPMethod conversion = null; + + //constructors + if( t instanceof ICPPClassType ){ + ICPPConstructor [] constructors = ((ICPPClassType)t).getConstructors(); + if( constructors.length > 0 ){ + if( constructors.length == 1 && constructors[0] instanceof IProblemBinding ) + constructor = null; + else { + LookupData data = new LookupData(); + data.forUserDefinedConversion = true; + data.functionParameters = new IType [] { source }; + IBinding binding = CPPSemantics.resolveFunction( data, constructors ); + if( binding instanceof ICPPConstructor ) + constructor = (ICPPConstructor) binding; + } + } + if( constructor != null && !constructor.isExplicit() ){ + constructorCost = checkStandardConversionSequence( t, target, false ); + } + } + + //conversion operators + if( s instanceof ICPPInternalClassType ){ + ICPPMethod [] ops = ((ICPPInternalClassType)s).getConversionOperators(); + if( ops.length > 0 && !(ops[0] instanceof IProblemBinding) ){ + Cost [] costs = null; + for (int i = 0; i < ops.length; i++) { + cost = checkStandardConversionSequence( ops[i].getType().getReturnType(), target, false ); + if( cost.rank != Cost.NO_MATCH_RANK ) + costs = (Cost[]) ArrayUtil.append( Cost.class, costs, cost ); + } + if( costs != null ){ + Cost best = costs[0]; + boolean bestIsBest = true; + int bestIdx = 0; + for (int i = 1; i < costs.length && costs[i] != null; i++) { + int comp = best.compare( costs[i] ); + if( comp == 0 ) + bestIsBest = false; + else if( comp > 0 ){ + best = costs[ bestIdx = i ]; + bestIsBest = true; + } + } + if( bestIsBest ){ + conversion = ops[ bestIdx ]; + conversionCost = best; + } + } + } + } + + //if both are valid, then the conversion is ambiguous + if( constructorCost != null && constructorCost.rank != Cost.NO_MATCH_RANK && + conversionCost != null && conversionCost.rank != Cost.NO_MATCH_RANK ) + { + cost = constructorCost; + cost.userDefined = Cost.AMBIGUOUS_USERDEFINED_CONVERSION; + cost.rank = Cost.USERDEFINED_CONVERSION_RANK; + } else { + if( constructorCost != null && constructorCost.rank != Cost.NO_MATCH_RANK ){ + cost = constructorCost; + cost.userDefined = constructor.hashCode(); + cost.rank = Cost.USERDEFINED_CONVERSION_RANK; + } else if( conversionCost != null && conversionCost.rank != Cost.NO_MATCH_RANK ){ + cost = conversionCost; + cost.userDefined = conversion.hashCode(); + cost.rank = Cost.USERDEFINED_CONVERSION_RANK; + } + } + return cost; + } + + /** + * Calculates the number of edges in the inheritance path of clazz to + * ancestorToFind, returning -1 if no inheritance relationship is found. + * @param clazz the class to search upwards from + * @param ancestorToFind the class to find in the inheritance graph + * @return the number of edges in the inheritance graph, or -1 if the specifide classes have + * no inheritance relation + * @throws DOMException + */ + private static int calculateInheritanceDepth(ICPPClassType clazz, ICPPClassType ancestorToFind) throws DOMException { + if(clazz == ancestorToFind || clazz.isSameType(ancestorToFind)) + return 0; + + ICPPBase [] bases = clazz.getBases(); + for(int i=0; i0) + return n+1; + } + } + } + + return -1; + } + + static private void conversion( Cost cost ) throws DOMException{ + IType src = cost.source; + IType trg = cost.target; + + cost.conversion = 0; + cost.detail = 0; + + IType[] sHolder= new IType[1], tHolder= new IType[1]; + IType s = getUltimateType( src, sHolder, true ); + IType t = getUltimateType( trg, tHolder, true ); + IType sPrev= sHolder[0], tPrev= tHolder[0]; + + if( src instanceof IBasicType && trg instanceof IPointerType ){ + //4.10-1 an integral constant expression of integer type that evaluates to 0 can be converted to a pointer type + IASTExpression exp = ((IBasicType)src).getValue(); + if( exp instanceof IASTLiteralExpression && + ((IASTLiteralExpression)exp).getKind() == IASTLiteralExpression.lk_integer_constant ) + { + try { + String val = exp.toString().toLowerCase().replace('u', '0'); + val.replace( 'l', '0' ); + if( Integer.decode( val ).intValue() == 0 ){ + cost.rank = Cost.CONVERSION_RANK; + cost.conversion = 1; + } + } catch( NumberFormatException e ) { + } + } + } else if( sPrev instanceof IPointerType ){ + //4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be + //converted to an rvalue of type "pointer to cv void" + if( tPrev instanceof IPointerType && t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void ){ + cost.rank = Cost.CONVERSION_RANK; + cost.conversion = 1; + cost.detail = 2; + return; + } + //4.10-3 An rvalue of type "pointer to cv D", where D is a class type can be converted + //to an rvalue of type "pointer to cv B", where B is a base class of D. + else if( s instanceof ICPPClassType && tPrev instanceof IPointerType && t instanceof ICPPClassType ){ + int depth= calculateInheritanceDepth( (ICPPClassType)s, (ICPPClassType) t ); + cost.rank= ( depth > -1 ) ? Cost.CONVERSION_RANK : Cost.NO_MATCH_RANK; + cost.conversion= ( depth > -1 ) ? depth : 0; + cost.detail= 1; + return; + } + // 4.12 if the target is a bool, we can still convert + else if(!(trg instanceof IBasicType && ((IBasicType)trg).getType() == ICPPBasicType.t_bool)) { + return; + } + } + + if( t instanceof IBasicType && s instanceof IBasicType || s instanceof IEnumeration ){ + //4.7 An rvalue of an integer type can be converted to an rvalue of another integer type. + //An rvalue of an enumeration type can be converted to an rvalue of an integer type. + cost.rank = Cost.CONVERSION_RANK; + cost.conversion = 1; + } else if( trg instanceof IBasicType && ((IBasicType)trg).getType() == ICPPBasicType.t_bool && s instanceof IPointerType ){ + //4.12 pointer or pointer to member type can be converted to an rvalue of type bool + cost.rank = Cost.CONVERSION_RANK; + cost.conversion = 1; + } else if( s instanceof ICPPPointerToMemberType && t instanceof ICPPPointerToMemberType ){ + //4.11-2 An rvalue of type "pointer to member of B of type cv T", where B is a class type, + //can be converted to an rvalue of type "pointer to member of D of type cv T" where D is a + //derived class of B + ICPPPointerToMemberType spm = (ICPPPointerToMemberType) s; + ICPPPointerToMemberType tpm = (ICPPPointerToMemberType) t; + IType st = spm.getType(); + IType tt = tpm.getType(); + if( st != null && tt != null && st.isSameType( tt ) ){ + int depth= calculateInheritanceDepth( tpm.getMemberOfClass(), spm.getMemberOfClass() ); + cost.rank= ( depth > -1 ) ? Cost.CONVERSION_RANK : Cost.NO_MATCH_RANK; + cost.conversion= ( depth > -1 ) ? depth : 0; + cost.detail= 1; + } + } + } + + static private void derivedToBaseConversion( Cost cost ) throws DOMException { + IType s = getUltimateType( cost.source, true ); + IType t = getUltimateType( cost.target, true ); + + if( cost.targetHadReference && s instanceof ICPPClassType && t instanceof ICPPClassType ){ + int depth= calculateInheritanceDepth( (ICPPClassType) s, (ICPPClassType) t ); + if(depth > -1){ + cost.rank= Cost.DERIVED_TO_BASE_CONVERSION; + cost.conversion= depth; + } + } + } + + /** + * + * @param source + * @param target + * @return int + * + * 4.5-1 char, signed char, unsigned char, short int or unsigned short int + * can be converted to int if int can represent all the values of the source + * type, otherwise they can be converted to unsigned int. + * 4.5-2 wchar_t or an enumeration can be converted to the first of the + * 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 + */ + static private void promotion( Cost cost ) throws DOMException{ + IType src = cost.source; + IType trg = cost.target; + + if( src.isSameType( trg ) ) + return; + + if( src instanceof IBasicType && trg instanceof IBasicType ){ + int sType = ((IBasicType)src).getType(); + int tType = ((IBasicType)trg).getType(); + if( ( tType == IBasicType.t_int && ( sType == IBasicType.t_int || //short, long , unsigned etc + sType == IBasicType.t_char || + sType == ICPPBasicType.t_bool || + sType == ICPPBasicType.t_wchar_t || + sType == IBasicType.t_unspecified ) ) || //treat unspecified as int + ( tType == IBasicType.t_double && sType == IBasicType.t_float ) ) + { + cost.promotion = 1; + } + } else if( src instanceof IEnumeration && trg instanceof IBasicType && + ( ((IBasicType)trg).getType() == IBasicType.t_int || + ((IBasicType)trg).getType() == IBasicType.t_unspecified ) ) + { + cost.promotion = 1; + } + + cost.rank = (cost.promotion > 0 ) ? Cost.PROMOTION_RANK : Cost.NO_MATCH_RANK; + } + + static private void qualificationConversion( Cost cost ) throws DOMException{ + boolean canConvert = true; + int requiredConversion = Cost.IDENTITY_RANK; + + IType s = cost.source, t = cost.target; + boolean constInEveryCV2k = true; + boolean firstPointer= true; + while( true ){ + s= getUltimateTypeViaTypedefs(s); + t= getUltimateTypeViaTypedefs(t); + IPointerType op1= s instanceof IPointerType ? (IPointerType) s : null; + IPointerType op2= t instanceof IPointerType ? (IPointerType) t : null; + + if( op1 == null && op2 == null ) + break; + else if( op1 == null ^ op2 == null) { + // 4.12 - pointer types can be converted to bool + if(t instanceof ICPPBasicType) { + if(((ICPPBasicType)t).getType() == ICPPBasicType.t_bool) { + canConvert= true; + requiredConversion = Cost.CONVERSION_RANK; + break; + } + } + canConvert = false; + break; + } else if( op1 instanceof ICPPPointerToMemberType ^ op2 instanceof ICPPPointerToMemberType ){ + canConvert = false; + break; + } + + //if const is in cv1,j then const is in cv2,j. Similary for volatile + if( ( op1.isConst() && !op2.isConst() ) || ( op1.isVolatile() && !op2.isVolatile() ) ) { + canConvert = false; + requiredConversion = Cost.NO_MATCH_RANK; + break; + } + //if cv1,j and cv2,j are different then const is in every cv2,k for 0 0 || cost.promotion > 0 ){ + result = cost.promotion - promotion; + } + if( conversion > 0 || cost.conversion > 0 ){ + if( detail == cost.detail ){ + result = cost.conversion - conversion; + } else { + result = cost.detail - detail; + } + } + + if( result == 0 ){ + if( cost.qualification != qualification ){ + return cost.qualification - qualification; + } else if( (cost.qualification == qualification) && qualification == 0 ){ + return 0; + } else { + IPointerType op1, op2; + IType t1 = cost.target, t2 = target; + int subOrSuper = 0; + while( true ){ + op1 = null; + op2 = null; + while( true ){ + if( t1 instanceof ITypedef ) + try { + t1 = ((ITypedef)t1).getType(); + } catch ( DOMException e ) { + t1 = e.getProblem(); + } + else { + if( t1 instanceof IPointerType ) + op1 = (IPointerType) t1; + break; + } + } + while( true ){ + if( t2 instanceof ITypedef ) + try { + t2 = ((ITypedef)t2).getType(); + } catch ( DOMException e ) { + t2 = e.getProblem(); + } + else { + if( t2 instanceof IPointerType ) + op1 = (IPointerType) t2; + break; + } + } + if( op1 == null || op2 == null ) + break; + + int cmp = ( op1.isConst() ? 1 : 0 ) + ( op1.isVolatile() ? 1 : 0 ) - + ( op2.isConst() ? 1 : 0 ) + ( op2.isVolatile() ? 1 : 0 ); + + if( subOrSuper == 0 ) + subOrSuper = cmp; + else if( subOrSuper > 0 ^ cmp > 0) { + result = -1; + break; + } + + } + if( result == -1 ){ + result = 0; + } else { + if( op1 == op2 ){ + result = subOrSuper; + } else { + result = op1 != null ? 1 : -1; + } + } + } + } + + return result; + } +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java new file mode 100644 index 00000000000..0f640f3e3c0 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java @@ -0,0 +1,417 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Bryan Wilkinson (QNX) + * Andrew Ferguson (Symbian) + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; +import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; +import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTFieldReference; +import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; +import org.eclipse.cdt.core.dom.ast.IASTIdExpression; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTTypeId; +import org.eclipse.cdt.core.dom.ast.IPointerType; +import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; +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.ICPPNamespaceScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; +import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; +import org.eclipse.cdt.core.parser.util.ObjectSet; +import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit; + +/** + * Context data for IASTName lookup + */ +class LookupData { + protected IASTName astName; + protected CPPASTTranslationUnit tu; + public Map> usingDirectives= Collections.emptyMap(); + public ObjectSet visited= new ObjectSet(1); //used to ensure we don't visit things more than once + public ObjectSet inheritanceChain; //used to detect circular inheritance + public ObjectSet associated = ObjectSet.EMPTY_SET; + + public boolean checkWholeClassScope = false; + public boolean ignoreUsingDirectives = false; + public boolean usingDirectivesOnly = false; + public boolean forceQualified = false; + public boolean forUserDefinedConversion = false; + public boolean forAssociatedScopes = false; + public boolean contentAssist = false; + public boolean prefixLookup = false; + public boolean typesOnly = false; + public boolean considerConstructors = false; + public Object foundItems = null; + public Object [] functionParameters; + public IASTNode [] templateArguments; + public ProblemBinding problem; + + + public LookupData( IASTName n ){ + astName = n; + tu= (CPPASTTranslationUnit) astName.getTranslationUnit(); + typesOnly = typesOnly(); + considerConstructors = considerConstructors(); + checkWholeClassScope = checkWholeClassScope(); + } + public LookupData(){ + astName = null; + } + public final char [] name () { + if( astName != null ) + return astName.toCharArray(); + return CPPSemantics.EMPTY_NAME_ARRAY; + } + public boolean includeBlockItem( IASTNode item ){ + if( astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return true; + if( ( astName != null && astName.getParent() instanceof IASTIdExpression ) || + item instanceof ICPPASTNamespaceDefinition || + (item instanceof IASTSimpleDeclaration && ((IASTSimpleDeclaration)item).getDeclSpecifier() instanceof IASTCompositeTypeSpecifier ) || + item instanceof ICPPASTTemplateDeclaration ) + { + return true; + } + return false; + } + private boolean typesOnly(){ + if( astName == null ) return false; + if( astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false; + IASTNode parent = astName.getParent(); + if( parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTElaboratedTypeSpecifier || + parent instanceof ICPPASTCompositeTypeSpecifier ) + return true; + if( parent instanceof ICPPASTQualifiedName ){ + IASTName [] ns = ((ICPPASTQualifiedName)parent).getNames(); + return ( astName != ns[ ns.length -1 ] ); + } + return false; + } + public boolean forUsingDeclaration(){ + if( astName == null ) return false; + if( astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false; + IASTNode p1 = astName.getParent(); + if( p1 instanceof ICPPASTUsingDeclaration ) + return true; + + if( p1 instanceof ICPPASTQualifiedName ){ + IASTNode p2 = p1.getParent(); + if( p2 instanceof ICPPASTUsingDeclaration ){ + IASTName [] ns = ((ICPPASTQualifiedName) p1 ).getNames(); + return (ns[ ns.length - 1 ] == astName); + } + } + return false; + } + public boolean forDefinition(){ + if( astName == null ) return false; + if( astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false; + + IASTName n = astName; + if( n.getParent() instanceof ICPPASTTemplateId ) + n = (IASTName) n.getParent(); + IASTNode p1 = n.getParent(); + if( p1 instanceof ICPPASTQualifiedName ){ + IASTName [] ns = ((ICPPASTQualifiedName)p1).getNames(); + if( ns[ns.length - 1] != n ) + return false; + p1 = p1.getParent(); + } + IASTNode p2 = p1.getParent(); + if( p1 instanceof IASTDeclarator && p2 instanceof IASTSimpleDeclaration ){ + return !( p2.getParent() instanceof ICPPASTExplicitTemplateInstantiation ); + } + return ( p1 instanceof IASTDeclarator && p2 instanceof IASTFunctionDefinition); + } + + public boolean forExplicitInstantiation(){ + if( astName == null ) return false; + if( astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false; + + IASTName n = astName; + if( n.getParent() instanceof ICPPASTTemplateId ) + n = (IASTName) n.getParent(); + IASTNode p1 = n.getParent(); + if( p1 instanceof ICPPASTQualifiedName ){ + IASTName [] ns = ((ICPPASTQualifiedName)p1).getNames(); + if( ns[ns.length - 1] != n ) + return false; + p1 = p1.getParent(); + } + IASTNode p2 = p1.getParent(); + if( p1 instanceof IASTDeclarator && p2 instanceof IASTSimpleDeclaration ){ + return ( p2.getParent() instanceof ICPPASTExplicitTemplateInstantiation ); + } + return false; + } + + private boolean considerConstructors(){ + if( astName == null ) return false; + if( astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false; + IASTNode p1 = astName.getParent(); + IASTNode p2 = p1.getParent(); + + if( p1 instanceof ICPPASTConstructorChainInitializer ) + return true; + if( p1 instanceof ICPPASTNamedTypeSpecifier && p2 instanceof IASTTypeId ) + return p2.getParent() instanceof ICPPASTNewExpression; + else if( p1 instanceof ICPPASTQualifiedName ){ + if( p2 instanceof ICPPASTFunctionDeclarator ){ + IASTName[] names = ((ICPPASTQualifiedName)p1).getNames(); + if( names.length >= 2 && names[ names.length - 1 ] == astName ) + return CPPVisitor.isConstructor( names[ names.length - 2 ], (IASTDeclarator) p2 ); + } else if( p2 instanceof ICPPASTNamedTypeSpecifier ){ + IASTNode p3 = p2.getParent(); + return p3 instanceof IASTTypeId && p3.getParent() instanceof ICPPASTNewExpression; + } else if( p2 instanceof IASTIdExpression ){ + return p2.getParent() instanceof IASTFunctionCallExpression; + } + } else if( p1 instanceof IASTFunctionCallExpression || p2 instanceof IASTFunctionCallExpression ) + return true; + return false; + } + public boolean qualified(){ + if( forceQualified ) return true; + if( astName == null ) return false; + if( astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false; + IASTNode p1 = astName.getParent(); + if( p1 instanceof ICPPASTQualifiedName ){ + final IASTName[] qnames = ((ICPPASTQualifiedName)p1).getNames(); + return qnames.length == 1 || qnames[0] != astName; + } + return p1 instanceof ICPPASTFieldReference; + } + public boolean functionCall(){ + if( astName == null ) return false; + if( astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false; + IASTNode p1 = astName.getParent(); + if( p1 instanceof ICPPASTQualifiedName ) + p1 = p1.getParent(); + return ( p1 instanceof IASTIdExpression && p1.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME ); + } + private boolean checkWholeClassScope() { + if( astName == null ) return false; + if( astName.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return true; + + IASTNode parent = astName.getParent(); + while( parent != null && !(parent instanceof IASTFunctionDefinition) ){ + parent = parent.getParent(); + } + if( parent instanceof IASTFunctionDefinition ){ + while( parent.getParent() instanceof ICPPASTTemplateDeclaration ) + parent = parent.getParent(); + if( parent.getPropertyInParent() != IASTCompositeTypeSpecifier.MEMBER_DECLARATION ) + return false; + + ASTNodeProperty prop = astName.getPropertyInParent(); + if( prop == ICPPASTQualifiedName.SEGMENT_NAME ) + prop = astName.getParent().getPropertyInParent(); + if( prop == IASTIdExpression.ID_NAME || + prop == IASTFieldReference.FIELD_NAME || + prop == ICASTFieldDesignator.FIELD_NAME || + prop == ICPPASTUsingDirective.QUALIFIED_NAME || + prop == ICPPASTUsingDeclaration.NAME || + prop == IASTFunctionCallExpression.FUNCTION_NAME || + prop == IASTNamedTypeSpecifier.NAME || + prop == ICPPASTConstructorChainInitializer.MEMBER_ID ) + { + return true; + } + } + return false; + } + + public boolean hasResults(){ + if( foundItems == null ) + return false; + if( foundItems instanceof Object [] ) + return ((Object[])foundItems).length != 0; + if( foundItems instanceof CharArrayObjectMap ) + return ((CharArrayObjectMap)foundItems).size() != 0; + return false; + } + /** + * an IType[] of function arguments, inluding the implied object argument + * @return + */ + public IType getImpliedObjectArgument() { + IType implied = null; + + if( astName != null ){ + IASTName tempName = astName; + while( tempName.getParent() instanceof IASTName ) + tempName = (IASTName) tempName.getParent(); + + ASTNodeProperty prop = tempName.getPropertyInParent(); + if( (prop == CPPSemantics.STRING_LOOKUP_PROPERTY && tempName.getParent() instanceof ICPPASTUnaryExpression) ) { + ICPPASTUnaryExpression unaryExp = (ICPPASTUnaryExpression) tempName.getParent(); + IASTExpression oprd= unaryExp.getOperand(); + return CPPVisitor.getExpressionType(oprd); + } else if( prop == IASTFieldReference.FIELD_NAME || + (prop == CPPSemantics.STRING_LOOKUP_PROPERTY && tempName.getParent() instanceof ICPPASTFieldReference) ) + { + ICPPASTFieldReference fieldRef = (ICPPASTFieldReference) tempName.getParent(); + implied = CPPVisitor.getExpressionType( fieldRef.getFieldOwner() ); + IType ultimateImplied= SemanticUtil.getUltimateTypeUptoPointers(implied); + if( prop != CPPSemantics.STRING_LOOKUP_PROPERTY && fieldRef.isPointerDereference() && ultimateImplied instanceof ICPPClassType) { + ICPPFunction operator= CPPSemantics.findOperator(fieldRef, (ICPPClassType) ultimateImplied); + try { + if(operator!=null) { + implied= operator.getType().getReturnType(); + } + } catch(DOMException de) { + return de.getProblem(); + } + } else if( fieldRef.isPointerDereference() && implied instanceof IPointerType ){ + try { + implied = ((IPointerType)implied).getType(); + } catch ( DOMException e ) { + implied = e.getProblem(); + } + } + } else if( prop == IASTIdExpression.ID_NAME ){ + IScope scope = CPPVisitor.getContainingScope( tempName ); + if( scope instanceof ICPPClassScope ){ + implied = ((ICPPClassScope)scope).getClassType(); + } else { + implied = CPPVisitor.getThisType( scope ); + if( implied instanceof IPointerType ){ + try { + implied = ((IPointerType)implied).getType(); + } catch ( DOMException e ) { + implied = e.getProblem(); + } + } + } + } else if( prop == CPPSemantics.STRING_LOOKUP_PROPERTY && tempName.getParent() instanceof IASTArraySubscriptExpression ){ + IASTExpression exp = ((IASTArraySubscriptExpression)tempName.getParent()).getArrayExpression(); + implied = CPPVisitor.getExpressionType( exp ); + } + } + return implied; + } + public boolean forFriendship() { + if( astName == null ) + return false; + IASTNode node = astName.getParent(); + while( node instanceof IASTName ) + node = node.getParent(); + + IASTDeclaration decl = null; + IASTDeclarator dtor = null; + if( node instanceof ICPPASTDeclSpecifier && node.getParent() instanceof IASTDeclaration ){ + decl = (IASTDeclaration) node.getParent(); + } else if( node instanceof IASTDeclarator ) { + dtor = (IASTDeclarator) node; + while( dtor.getParent() instanceof IASTDeclarator ) + dtor = (IASTDeclarator) dtor.getParent(); + if( !(dtor.getParent() instanceof IASTDeclaration) ) + return false; + decl = (IASTDeclaration) dtor.getParent(); + } else { + return false; + } + if( decl instanceof IASTSimpleDeclaration ){ + IASTSimpleDeclaration simple = (IASTSimpleDeclaration) decl; + if( ! ((ICPPASTDeclSpecifier)simple.getDeclSpecifier()).isFriend() ) + return false; + if( dtor != null ) + return true; + return simple.getDeclarators().length == 0; + } else if( decl instanceof IASTFunctionDefinition ){ + IASTFunctionDefinition fnDef = (IASTFunctionDefinition) decl; + if( ! ((ICPPASTDeclSpecifier)fnDef.getDeclSpecifier()).isFriend() ) + return false; + return ( dtor != null ); + } + return false; + } + + public boolean checkAssociatedScopes() { + if( astName == null || astName instanceof ICPPASTQualifiedName ) + return false; + IASTNode parent = astName.getParent(); + if( parent instanceof ICPPASTQualifiedName ){ + IASTName [] ns = ((ICPPASTQualifiedName)parent).getNames(); + if( ns[ ns.length - 1] != astName ) + return false; + } + return functionCall() && (associated.size() > 0); + } + public boolean checkClassContainingFriend() { + if( astName == null || astName instanceof ICPPASTQualifiedName ) + return false; + + IASTNode p = astName.getParent(); + ASTNodeProperty prop = null; + while( p != null ){ + prop = p.getPropertyInParent(); + if( prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT || prop == IASTDeclarator.DECLARATOR_NAME ) + return false; + if( p instanceof IASTDeclarator && !(((IASTDeclarator)p).getName() instanceof ICPPASTQualifiedName) ) + return false; + if( p instanceof IASTDeclaration ){ + if( prop == IASTCompositeTypeSpecifier.MEMBER_DECLARATION ){ + if( p instanceof IASTSimpleDeclaration ){ + ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)p).getDeclSpecifier(); + return declSpec.isFriend(); + } else if( p instanceof IASTFunctionDefinition ){ + ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)p).getDeclSpecifier(); + return declSpec.isFriend(); + } + } else { + return false; + } + } + p = p.getParent(); + } + return false; + } + public boolean preferTemplateFunctions() { + if( astName == null ) + return false; + return (astName instanceof ICPPASTTemplateId || astName.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME ); + } +} \ 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 new file mode 100644 index 00000000000..9351265d5bd --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Bryan Wilkinson (QNX) + * Andrew Ferguson (Symbian) + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; + +import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IPointerType; +import org.eclipse.cdt.core.dom.ast.IQualifierType; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; + +/** + * + */ +public class SemanticUtil { + public static IType getUltimateType(IType type, boolean stopAtPointerToMember) { + return getUltimateType(type, null, stopAtPointerToMember); + } + + static IType getUltimateType(IType type, IType[] lastPointerType, boolean stopAtPointerToMember) { + try { + while( true ){ + if( type instanceof ITypedef ) + type= ((ITypedef)type).getType(); + else if( type instanceof IQualifierType ) + type= ((IQualifierType)type).getType(); + else if( stopAtPointerToMember && type instanceof ICPPPointerToMemberType ) + return type; + else if( type instanceof IPointerType ) { + if(lastPointerType!=null) { + lastPointerType[0]= type; + } + type= ((IPointerType) type).getType(); + } else if( type instanceof ICPPReferenceType ) + type= ((ICPPReferenceType)type).getType(); + else + return type; + + } + } catch ( DOMException e ) { + return e.getProblem(); + } + } + + /** + * Descends into type containers, stopping at pointer or + * pointer-to-member types. + * @param type + * @return the ultimate type contained inside the specified type + */ + public static IType getUltimateTypeUptoPointers(IType type){ + try { + while( true ){ + if( type instanceof ITypedef ) + type = ((ITypedef)type).getType(); + else if( type instanceof IQualifierType ) + type = ((IQualifierType)type).getType(); + else if( type instanceof ICPPReferenceType ) + type = ((ICPPReferenceType)type).getType(); + else + return type; + } + } catch ( DOMException e ) { + return e.getProblem(); + } + } + + /** + * Unravels a type by following purely typedefs + * @param type + * @return + */ + static IType getUltimateTypeViaTypedefs(IType type) { + try { + while(type instanceof ITypedef) { + type= ((ITypedef)type).getType(); + } + } catch(DOMException e) { + type= e.getProblem(); + } + return type; + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexCPPSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexCPPSignatureUtil.java index deae0258b96..248f31deed5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexCPPSignatureUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexCPPSignatureUtil.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.parser.util.ObjectMap; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.core.runtime.CoreException; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/AbstractCompositeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/AbstractCompositeFactory.java index 64db26166cf..197e1cb1311 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/AbstractCompositeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/AbstractCompositeFactory.java @@ -19,8 +19,8 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.internal.core.index.CIndex; import org.eclipse.cdt.internal.core.index.DefaultFragmentBindingComparator; -import org.eclipse.cdt.internal.core.index.IIndexFragmentBindingComparator; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; +import org.eclipse.cdt.internal.core.index.IIndexFragmentBindingComparator; import org.eclipse.cdt.internal.core.pdom.dom.PDOMFragmentBindingComparator; import org.eclipse.core.runtime.CoreException; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java index 11628f08af7..a71e8b510d0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.parser.util.ObjectMap; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java index 3721c745e7f..ea9f2b2e526 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java @@ -23,8 +23,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ObjectMap; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.index.CIndex; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPDeferredClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPDeferredClassInstance.java index bbf6e5959ab..d697e05187d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPDeferredClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPDeferredClassInstance.java @@ -19,9 +19,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.parser.util.ObjectMap; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeComparator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeComparator.java index 250e3715dea..dc4c15cecbd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeComparator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeComparator.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.db; +import java.io.IOException; + import org.eclipse.core.runtime.CoreException; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeVisitor.java index 636ddd89eab..b0f2ca73c07 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeVisitor.java @@ -11,6 +11,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.db; +import java.io.IOException; + import org.eclipse.core.runtime.CoreException; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFragmentBindingComparator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFragmentBindingComparator.java index a4fb24642e4..a42968c4822 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFragmentBindingComparator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFragmentBindingComparator.java @@ -10,8 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom; -import org.eclipse.cdt.internal.core.index.IIndexFragmentBindingComparator; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; +import org.eclipse.cdt.internal.core.index.IIndexFragmentBindingComparator; /** * {@link IIndexFragmentBindingComparator} suitable for comparing two PDOMBindings diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java index 4a76fc42309..f502726e3db 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java @@ -37,8 +37,8 @@ import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java index 965cd9ed5a9..cd87435978d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java @@ -38,9 +38,10 @@ import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBase; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexType; @@ -160,7 +161,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements IBinding origClass = origBase.getBaseClass(); if (origClass instanceof IType) { IType specClass = CPPTemplates.instantiateType((IType) origClass, getArgumentMap()); - specClass = CPPSemantics.getUltimateType(specClass, true); + specClass = SemanticUtil.getUltimateType(specClass, true); if (specClass instanceof IBinding) { ((ICPPInternalBase)specBase).setBaseClass((IBinding) specClass); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java index d92399b3bb2..802b28800a4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java @@ -42,9 +42,9 @@ import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.pdom.PDOM; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java index 84f1c0a5168..eac44567fe6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.Util; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java index 4057ad7d1ea..b997d8eda6a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java @@ -26,8 +26,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java index ab00c1906c3..0e5de032ce0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java @@ -44,7 +44,7 @@ import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredClassInstance.java index e041677c35d..f6cf73df756 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredClassInstance.java @@ -24,9 +24,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.parser.util.ObjectMap; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionTemplate.java index 9db85d11167..fc5a47229ae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionTemplate.java @@ -33,9 +33,9 @@ import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunctionInstance; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.pdom.PDOM; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionTemplateSpecialization.java index 156052adab6..89addf3d818 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionTemplateSpecialization.java @@ -23,8 +23,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunctionInstance; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner; 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 714502cf97e..0f8b2c347a9 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 @@ -71,7 +71,7 @@ import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.composite.CompositeScope; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java index 54ee7a39d61..119e5fd1c2f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.parser.util.ArrayUtil; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.pdom.PDOM; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java index 0b7e18ddfcf..ce26aa4ce2a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java @@ -35,7 +35,7 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.parser.util.CharArrayUtils; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java index aa91f79a5bc..9f82028ce52 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java @@ -97,7 +97,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java index 7f433b662cc..aded064fce6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java @@ -68,7 +68,7 @@ import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitTypedef; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates.CPPImplicitFunctionTemplate; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.CPPImplicitFunctionTemplate; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java index 84438dce229..771c905f73a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java @@ -89,7 +89,7 @@ import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.model.ASTCache; import org.eclipse.cdt.internal.ui.editor.ASTProvider; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java index 10d601e27d6..ce55e8f4543 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java @@ -61,7 +61,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;