mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
222748: refactor semantic routines to separate package
This commit is contained in:
parent
d9b287728b
commit
8bc2a7437a
120 changed files with 1501 additions and 1158 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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<bindings.length; i++) {
|
||||
assertTrue("expected typedef, got "+bindings[i], bindings[i] instanceof ITypedef);
|
||||
bnames.add(bindings[i].getName());
|
||||
IType type= CPPSemantics.getUltimateType((IType)bindings[i], false);
|
||||
IType type= SemanticUtil.getUltimateType((IType)bindings[i], false);
|
||||
|
||||
if(bindings[i].getName().equals("J")) {
|
||||
assertTrue(type instanceof IFunctionType);
|
||||
|
|
|
@ -46,6 +46,7 @@ Export-Package: org.eclipse.cdt.core,
|
|||
org.eclipse.cdt.internal.core.dom.parser;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.dom.parser.c;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.dom.parser.cpp;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.dom.parser.cpp.semantics,
|
||||
org.eclipse.cdt.internal.core.dom.rewrite;x-friends:="org.eclipse.cdt.core.tests,org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.dom.rewrite.astwriter;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;x-internal:=true,
|
||||
|
|
|
@ -79,7 +79,7 @@ import org.eclipse.cdt.core.parser.Keywords;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTDeclarationAmbiguity;
|
||||
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.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
package org.eclipse.cdt.core.dom;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
||||
/**
|
||||
* Common interface for names in the index and the AST.
|
||||
|
|
|
@ -41,8 +41,8 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CASTTypeId;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* This is a utility class to help convert AST elements to Strings corresponding to the
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.parser;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
|
||||
/**
|
||||
* Interface for an AST source code parser.
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
|
||||
/**
|
||||
* C++ parser extension configuration interface.
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
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.parser.ParserMessages;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
public abstract class CPPASTAmbiguity extends CPPASTNode {
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
public class CPPASTAmbiguousExpression extends CPPASTAmbiguity implements
|
||||
IASTAmbiguousExpression {
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -24,6 +24,8 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -17,6 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider.CPPBuiltinParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent;
|
||||
|
||||
|
@ -169,14 +170,14 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
}
|
||||
|
||||
// bug 217102: namespace scopes from the index have to be mapped back to the AST.
|
||||
IScope mapToASTScope(IIndexScope scope) {
|
||||
public IScope mapToASTScope(IIndexScope scope) {
|
||||
return fScopeMapper.mapToASTScope(scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores directives from the index into this scope.
|
||||
*/
|
||||
void handleAdditionalDirectives(ICPPNamespaceScope scope) {
|
||||
public void handleAdditionalDirectives(ICPPNamespaceScope scope) {
|
||||
fScopeMapper.handleAdditionalDirectives(scope);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
|
@ -30,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
||||
/**
|
||||
|
@ -60,7 +63,7 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
IBinding base = bindings[i].getBaseClass();
|
||||
if (base instanceof IType) {
|
||||
IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
|
||||
specBase = CPPSemantics.getUltimateType(specBase, false);
|
||||
specBase = getUltimateType(specBase, false);
|
||||
if (specBase instanceof IBinding) {
|
||||
((ICPPInternalBase) specBinding).setBaseClass((IBinding) specBase);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,9 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||
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.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -37,6 +37,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
||||
/**
|
||||
|
@ -80,7 +83,7 @@ public class CPPClassSpecialization extends CPPSpecialization implements
|
|||
IBinding base = bindings[i].getBaseClass();
|
||||
if (base instanceof IType) {
|
||||
IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
|
||||
specBase = CPPSemantics.getUltimateType(specBase, false);
|
||||
specBase = SemanticUtil.getUltimateType(specBase, false);
|
||||
if (specBase instanceof IBinding) {
|
||||
((ICPPInternalBase)specBinding).setBaseClass((IBinding)specBase);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||
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.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -203,9 +206,8 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
|||
public boolean isFullyCached() throws DOMException {
|
||||
ICPPScope origScope = (ICPPScope) getOriginalClass().getCompositeScope();
|
||||
if (!ASTInternal.isFullyCached(origScope)) {
|
||||
CPPSemantics.LookupData data = new CPPSemantics.LookupData();
|
||||
try {
|
||||
CPPSemantics.lookupInScope(data, origScope, null);
|
||||
CPPSemantics.lookupInScope(null, origScope, null);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
|||
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.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -25,6 +25,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.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ 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.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* Represents a partially instantiated class template, where instance arguments contain at least one
|
||||
|
|
|
@ -27,6 +27,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.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.eclipse.cdt.internal.core.dom.Linkage;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
|||
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.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -30,6 +30,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -35,6 +35,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.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
|||
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.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* The CPPImplicitFunction is used to represent implicit functions that exist on the translation
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
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.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
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.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
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.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.parser.util.ObjectSet;
|
|||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.LookupData;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
|
||||
/**
|
||||
|
@ -40,8 +40,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
|
|||
*/
|
||||
public ICPPUsingDirective[] getUsingDirectives() throws DOMException {
|
||||
if (!isFullyCached()) {
|
||||
LookupData ld= new LookupData();
|
||||
CPPSemantics.lookupInScope(ld, this, null);
|
||||
CPPSemantics.lookupInScope(null, this, null);
|
||||
}
|
||||
return (ICPPUsingDirective[]) ArrayUtil.trim( ICPPUsingDirective.class, usings, true );
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
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.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -42,6 +42,8 @@ import org.eclipse.cdt.core.parser.util.ObjectSet;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
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.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
@ -110,7 +112,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
}
|
||||
}
|
||||
|
||||
boolean canDenoteScopeMember(ICPPASTQualifiedName name) {
|
||||
public boolean canDenoteScopeMember(ICPPASTQualifiedName name) {
|
||||
IScope scope= this;
|
||||
IASTName[] na= name.getNames();
|
||||
try {
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,6 +46,8 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||
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.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -24,6 +24,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
@ -137,7 +139,7 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
|
|||
}
|
||||
}
|
||||
if (t != null) {
|
||||
t = CPPSemantics.getUltimateType(t, false);
|
||||
t = SemanticUtil.getUltimateType(t, false);
|
||||
if (t instanceof ICPPClassType) {
|
||||
IScope s = ((ICPPClassType) t).getCompositeScope();
|
||||
if (s != null && ASTInternal.isFullyCached(s))
|
||||
|
|
|
@ -21,6 +21,7 @@ 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.semantics.CPPTemplates;
|
||||
|
||||
/*
|
||||
* Represents a partially instantiated C++ class template, declaration of which is not yet available.
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* Represents a using-directive found in the AST.
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,6 +44,8 @@ import org.eclipse.cdt.core.parser.util.ObjectSet;
|
|||
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.CPPClassType.CPPClassTypeProblem;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* Holds common implementation of methods for ICPPClassType implementations that have
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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);
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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 <code>clazz</code> to
|
||||
* <code>ancestorToFind</code>, 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; i<bases.length; i++) {
|
||||
IBinding base = bases[i].getBaseClass();
|
||||
if(base instanceof IType) {
|
||||
IType tbase= (IType) base;
|
||||
if( tbase.isSameType(ancestorToFind) ||
|
||||
(ancestorToFind instanceof ICPPSpecialization && /*allow some flexibility with templates*/
|
||||
((IType)((ICPPSpecialization)ancestorToFind).getSpecializedBinding()).isSameType(tbase) ) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
tbase= getUltimateTypeViaTypedefs(tbase);
|
||||
if(tbase instanceof ICPPClassType) {
|
||||
int n= calculateInheritanceDepth((ICPPClassType) tbase, ancestorToFind );
|
||||
if(n>0)
|
||||
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<k<j
|
||||
if( !constInEveryCV2k && ( op1.isConst() != op2.isConst() ||
|
||||
op1.isVolatile() != op2.isVolatile() ) )
|
||||
{
|
||||
canConvert = false;
|
||||
requiredConversion = Cost.NO_MATCH_RANK;
|
||||
break;
|
||||
}
|
||||
constInEveryCV2k &= (firstPointer || op2.isConst());
|
||||
s = op1.getType();
|
||||
t = op2.getType();
|
||||
firstPointer= false;
|
||||
}
|
||||
|
||||
if( s instanceof IQualifierType ^ t instanceof IQualifierType ){
|
||||
if( t instanceof IQualifierType ){
|
||||
if (!constInEveryCV2k) {
|
||||
canConvert= false;
|
||||
requiredConversion= Cost.NO_MATCH_RANK;
|
||||
}
|
||||
else {
|
||||
canConvert = true;
|
||||
requiredConversion = Cost.CONVERSION_RANK;
|
||||
}
|
||||
} else {
|
||||
//4.2-2 a string literal can be converted to pointer to char
|
||||
if( t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_char &&
|
||||
s instanceof IQualifierType )
|
||||
{
|
||||
IType qt = ((IQualifierType)s).getType();
|
||||
if( qt instanceof IBasicType ){
|
||||
IASTExpression val = ((IBasicType)qt).getValue();
|
||||
canConvert = (val != null &&
|
||||
val instanceof IASTLiteralExpression &&
|
||||
((IASTLiteralExpression)val).getKind() == IASTLiteralExpression.lk_string_literal );
|
||||
} else {
|
||||
canConvert = false;
|
||||
requiredConversion = Cost.NO_MATCH_RANK;
|
||||
}
|
||||
} else {
|
||||
canConvert = false;
|
||||
requiredConversion = Cost.NO_MATCH_RANK;
|
||||
}
|
||||
}
|
||||
} else if( s instanceof IQualifierType && t instanceof IQualifierType ){
|
||||
IQualifierType qs = (IQualifierType) s, qt = (IQualifierType) t;
|
||||
if( qs.isConst() == qt.isConst() && qs.isVolatile() == qt.isVolatile() ) {
|
||||
requiredConversion = Cost.IDENTITY_RANK;
|
||||
}
|
||||
else if( (qs.isConst() && !qt.isConst()) || (qs.isVolatile() && !qt.isVolatile()) || !constInEveryCV2k ) {
|
||||
requiredConversion = Cost.NO_MATCH_RANK;
|
||||
canConvert= false;
|
||||
}
|
||||
else
|
||||
requiredConversion = Cost.CONVERSION_RANK;
|
||||
} else if( constInEveryCV2k && !canConvert ){
|
||||
canConvert = true;
|
||||
requiredConversion = Cost.CONVERSION_RANK;
|
||||
int i = 1;
|
||||
for( IType type = s; canConvert == true && i == 1; type = t, i++ ){
|
||||
while( type instanceof ITypeContainer ){
|
||||
if( type instanceof IQualifierType )
|
||||
canConvert = false;
|
||||
else if( type instanceof IPointerType ){
|
||||
canConvert = !((IPointerType)type).isConst() && !((IPointerType)type).isVolatile();
|
||||
}
|
||||
if( !canConvert ){
|
||||
requiredConversion = Cost.NO_MATCH_RANK;
|
||||
break;
|
||||
}
|
||||
type = ((ITypeContainer)type).getType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cost.qualification = requiredConversion;
|
||||
if( canConvert == true ){
|
||||
cost.rank = Cost.LVALUE_OR_QUALIFICATION_RANK;
|
||||
}
|
||||
}
|
||||
|
||||
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 boolean isCompleteType( IType type ){
|
||||
type = getUltimateType( type, false );
|
||||
if( type instanceof ICPPClassType && type instanceof ICPPInternalBinding )
|
||||
return (((ICPPInternalBinding)type).getDefinition() != null );
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
/*******************************************************************************
|
||||
* 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.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
|
||||
/**
|
||||
* The cost of an implicit conversion sequence.
|
||||
*
|
||||
* See [over.best.ics] 13.3.3.1.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<ICPPNamespaceScope, List<ICPPNamespaceScope>> 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 );
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue