mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixes order of ambiguity resolution, bug 259373.
This commit is contained in:
parent
29d9ee28c1
commit
a3c36bd408
28 changed files with 724 additions and 537 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for C model builder bugs.
|
* Tests for C model builder bugs.
|
||||||
|
@ -56,7 +55,6 @@ public class CModelBuilderBugsTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testModelBuilderBug222398() throws Exception {
|
public void testModelBuilderBug222398() throws Exception {
|
||||||
CPPASTNameBase.sAllowNameComputation= true;
|
|
||||||
IStructure clazz= (IStructure) fTU.getElement("Test");
|
IStructure clazz= (IStructure) fTU.getElement("Test");
|
||||||
assertNotNull(clazz);
|
assertNotNull(clazz);
|
||||||
ICElement[] methods= clazz.getChildren();
|
ICElement[] methods= clazz.getChildren();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -4390,7 +4390,9 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T> class complex {};
|
// template<typename T> class complex {
|
||||||
|
// complex(T,T) {}
|
||||||
|
// };
|
||||||
// template<class T> class Array {
|
// template<class T> class Array {
|
||||||
// T* v;
|
// T* v;
|
||||||
// int sz;
|
// int sz;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -6374,4 +6374,33 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
ba.assertNonProblem("a; //4", 1, ICPPField.class);
|
ba.assertNonProblem("a; //4", 1, ICPPField.class);
|
||||||
ba.assertNonProblem("a; //5", 1, ICPPField.class);
|
ba.assertNonProblem("a; //5", 1, ICPPField.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int a,b,c,d ;
|
||||||
|
// class X {
|
||||||
|
// void m() {
|
||||||
|
// T* a;
|
||||||
|
// I* b;
|
||||||
|
// S1* c;
|
||||||
|
// S2* d;
|
||||||
|
// }
|
||||||
|
// typedef int T;
|
||||||
|
// int I;
|
||||||
|
// typedef int S1 (int(T)); // resolve this ambiguity first
|
||||||
|
// typedef int S2 (int(t)); // resolve this ambiguity first
|
||||||
|
// };
|
||||||
|
public void testOrderOfAmbiguityResolution_259373() throws Exception {
|
||||||
|
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
|
ICPPVariable a= ba.assertNonProblem("a;", 1);
|
||||||
|
assertInstance(a.getType(), IPointerType.class);
|
||||||
|
ICPPVariable b= ba.assertNonProblem("b;", 1);
|
||||||
|
assertInstance(b.getType(), IBasicType.class);
|
||||||
|
ICPPVariable c= ba.assertNonProblem("c;", 1);
|
||||||
|
assertInstance(c.getType(), IPointerType.class);
|
||||||
|
ITypedef s1= (ITypedef) ((IPointerType) c.getType()).getType();
|
||||||
|
assertInstance(((IFunctionType) s1.getType()).getParameterTypes()[0], IPointerType.class);
|
||||||
|
ICPPVariable d= ba.assertNonProblem("d;", 1);
|
||||||
|
assertInstance(d.getType(), IPointerType.class);
|
||||||
|
ITypedef s2= (ITypedef) ((IPointerType) d.getType()).getType();
|
||||||
|
assertInstance(((IFunctionType) s2.getType()).getParameterTypes()[0], IBasicType.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -464,8 +464,6 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1
|
// A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1
|
||||||
// A <int*, int*, 2> a5; //ambiguous, matches #3 & #5.
|
// A <int*, int*, 2> a5; //ambiguous, matches #3 & #5.
|
||||||
public void test_14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{
|
public void test_14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{
|
||||||
CPPASTNameBase.sAllowNameComputation= true;
|
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
@ -2756,7 +2754,6 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// C c1;
|
// C c1;
|
||||||
// C<> c2; // ok - default args
|
// C<> c2; // ok - default args
|
||||||
public void testMissingTemplateArgumentLists() throws Exception {
|
public void testMissingTemplateArgumentLists() throws Exception {
|
||||||
CPPASTNameBase.sAllowNameComputation=true;
|
|
||||||
BindingAssertionHelper ba=new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper ba=new BindingAssertionHelper(getAboveComment(), true);
|
||||||
ba.assertProblem("B b1", 1);
|
ba.assertProblem("B b1", 1);
|
||||||
ba.assertNonProblem("B<> b2", 1, ICPPTemplateDefinition.class, ICPPClassType.class);
|
ba.assertNonProblem("B<> b2", 1, ICPPTemplateDefinition.class, ICPPClassType.class);
|
||||||
|
@ -2929,7 +2926,6 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
//
|
//
|
||||||
// A<int> aint; // should be an error
|
// A<int> aint; // should be an error
|
||||||
public void testTypeArgumentToNonTypeParameter() throws Exception {
|
public void testTypeArgumentToNonTypeParameter() throws Exception {
|
||||||
CPPASTNameBase.sAllowNameComputation=true;
|
|
||||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
ba.assertProblem("A<int>", 6);
|
ba.assertProblem("A<int>", 6);
|
||||||
}
|
}
|
||||||
|
@ -3458,7 +3454,8 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// T::b.f();
|
// T::b.f();
|
||||||
// T::b.f().d;
|
// T::b.f().d;
|
||||||
// T::f1();
|
// T::f1();
|
||||||
// T.x; T.y();
|
// T v;
|
||||||
|
// v.x; v.y();
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
public void testTypeOfUnknownReferences_Bug257194a() throws Exception {
|
public void testTypeOfUnknownReferences_Bug257194a() throws Exception {
|
||||||
|
@ -3482,7 +3479,8 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// T::b->f();
|
// T::b->f();
|
||||||
// T::b->f()->d;
|
// T::b->f()->d;
|
||||||
// T::f1();
|
// T::f1();
|
||||||
// T->x; T->y();
|
// T v;
|
||||||
|
// v->x; v->y();
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
public void testTypeOfUnknownReferences_Bug257194b() throws Exception {
|
public void testTypeOfUnknownReferences_Bug257194b() throws Exception {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -1110,16 +1110,17 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
assertInstances( col, counter, 3 );
|
assertInstances( col, counter, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testThrowStatement() throws Exception
|
public void testThrowStatement() throws Exception {
|
||||||
{
|
IASTTranslationUnit tu = parse("class A { }; void foo() throw ( A ) { A a; throw a; throw; } "); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( "class A { }; void foo() throw ( A ) { throw A; throw; } "); //$NON-NLS-1$
|
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals( col.size(), 4 );
|
assertEquals(6, col.size());
|
||||||
ICompositeType A = (ICompositeType) col.getName(0).resolveBinding();
|
ICompositeType A = (ICompositeType) col.getName(0).resolveBinding();
|
||||||
|
|
||||||
assertInstances(col, A, 3);
|
assertInstances(col, A, 3);
|
||||||
|
|
||||||
|
IVariable a = (IVariable) col.getName(4).resolveBinding();
|
||||||
|
assertInstances(col, a, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScoping() throws Exception
|
public void testScoping() throws Exception
|
||||||
|
|
|
@ -0,0 +1,200 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2009 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic visitor for ast-nodes.
|
||||||
|
* <p> Clients may subclass. </p>
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVisitor, ICASTVisitor {
|
||||||
|
public ASTGenericVisitor(boolean visitNodes) {
|
||||||
|
super(visitNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int genericVisit(IASTNode node) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int genericLeave(IASTNode node) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int visit(ICPPASTBaseSpecifier baseSpecifier) {
|
||||||
|
return genericVisit(baseSpecifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||||
|
return genericVisit(namespaceDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int visit(ICPPASTTemplateParameter templateParameter) {
|
||||||
|
return genericVisit(templateParameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTArrayModifier arrayModifier) {
|
||||||
|
return genericVisit(arrayModifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTDeclaration declaration) {
|
||||||
|
return genericVisit(declaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTDeclarator declarator) {
|
||||||
|
return genericVisit(declarator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTDeclSpecifier declSpec) {
|
||||||
|
return genericVisit(declSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTEnumerator enumerator) {
|
||||||
|
return genericVisit(enumerator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTExpression expression) {
|
||||||
|
return genericVisit(expression);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTInitializer initializer) {
|
||||||
|
return genericVisit(initializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTName name) {
|
||||||
|
return genericVisit(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTParameterDeclaration parameterDeclaration) {
|
||||||
|
return genericVisit(parameterDeclaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTProblem problem) {
|
||||||
|
return genericVisit(problem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTStatement statement) {
|
||||||
|
return genericVisit(statement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTTranslationUnit tu) {
|
||||||
|
return genericVisit(tu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTTypeId typeId) {
|
||||||
|
return genericVisit(typeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int visit(ICASTDesignator designator) {
|
||||||
|
return genericVisit(designator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int leave(ICASTDesignator designator) {
|
||||||
|
return genericLeave(designator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int leave(ICPPASTBaseSpecifier baseSpecifier) {
|
||||||
|
return genericLeave(baseSpecifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int leave(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||||
|
return genericLeave(namespaceDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int leave(ICPPASTTemplateParameter templateParameter) {
|
||||||
|
return genericLeave(templateParameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTArrayModifier arrayModifier) {
|
||||||
|
return genericLeave(arrayModifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTDeclaration declaration) {
|
||||||
|
return genericLeave(declaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTDeclarator declarator) {
|
||||||
|
return genericLeave(declarator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTDeclSpecifier declSpec) {
|
||||||
|
return genericLeave(declSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTEnumerator enumerator) {
|
||||||
|
return genericLeave(enumerator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTExpression expression) {
|
||||||
|
return genericLeave(expression);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTInitializer initializer) {
|
||||||
|
return genericLeave(initializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTName name) {
|
||||||
|
return genericLeave(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTParameterDeclaration parameterDeclaration) {
|
||||||
|
return genericLeave(parameterDeclaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTProblem problem) {
|
||||||
|
return genericLeave(problem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTStatement statement) {
|
||||||
|
return genericLeave(statement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTTranslationUnit tu) {
|
||||||
|
return genericLeave(tu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTTypeId typeId) {
|
||||||
|
return genericLeave(typeId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for all visitors to traverse ast nodes. <br>
|
* Abstract base class for all visitors to traverse ast nodes. <br>
|
||||||
|
@ -23,6 +24,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
||||||
*
|
*
|
||||||
* To visit c- or c++-specific nodes you need to implement {@link ICASTVisitor}
|
* To visit c- or c++-specific nodes you need to implement {@link ICASTVisitor}
|
||||||
* and/or {@link ICPPASTVisitor} in addition to deriving from this class.
|
* and/or {@link ICPPASTVisitor} in addition to deriving from this class.
|
||||||
|
*
|
||||||
|
* <p> Clients may subclass. </p>
|
||||||
*/
|
*/
|
||||||
public abstract class ASTVisitor {
|
public abstract class ASTVisitor {
|
||||||
/**
|
/**
|
||||||
|
@ -116,6 +119,12 @@ public abstract class ASTVisitor {
|
||||||
*/
|
*/
|
||||||
public boolean shouldVisitTemplateParameters = false;
|
public boolean shouldVisitTemplateParameters = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For internal use, only.
|
||||||
|
* @noreference This field is not intended to be referenced by clients.
|
||||||
|
*/
|
||||||
|
public boolean shouldVisitAmbiguousNodes = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a visitor that does not visit any kind of node per default.
|
* Creates a visitor that does not visit any kind of node per default.
|
||||||
*/
|
*/
|
||||||
|
@ -274,4 +283,15 @@ public abstract class ASTVisitor {
|
||||||
public int leave( IASTComment comment){
|
public int leave( IASTComment comment){
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For internal use, only. When {@link ASTVisitor#shouldVisitAmbiguousNodes} is set to true, the
|
||||||
|
* visitor will be called for ambiguous nodes. However, the children of an ambiguous will not be
|
||||||
|
* traversed.
|
||||||
|
* @nooverride This method is not intended to be re-implemented or extended by clients.
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
|
*/
|
||||||
|
public int visit(ASTAmbiguousNode astAmbiguousNode) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,11 +13,14 @@ package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +62,15 @@ public abstract class ASTAmbiguousNode extends ASTNode {
|
||||||
protected abstract IScope getAffectedScope();
|
protected abstract IScope getAffectedScope();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor visitor) {
|
public final boolean accept(ASTVisitor visitor) {
|
||||||
|
if (visitor.shouldVisitAmbiguousNodes && visitor.visit(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// alternatives are not visited on purpose.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resolveAmbiguity(ASTVisitor resolver) {
|
||||||
final IScope scope= getAffectedScope();
|
final IScope scope= getAffectedScope();
|
||||||
final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent();
|
final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent();
|
||||||
IASTNode nodeToReplace= this;
|
IASTNode nodeToReplace= this;
|
||||||
|
@ -83,7 +94,7 @@ public abstract class ASTAmbiguousNode extends ASTNode {
|
||||||
nodeToReplace= alternative;
|
nodeToReplace= alternative;
|
||||||
|
|
||||||
// handle nested ambiguities first, otherwise we cannot visit the alternative
|
// handle nested ambiguities first, otherwise we cannot visit the alternative
|
||||||
alternative.accept(visitor);
|
alternative.accept(resolver);
|
||||||
|
|
||||||
// find nested names
|
// find nested names
|
||||||
final NameCollector nameCollector= new NameCollector();
|
final NameCollector nameCollector= new NameCollector();
|
||||||
|
@ -97,6 +108,12 @@ public abstract class ASTAmbiguousNode extends ASTNode {
|
||||||
IBinding b= name.resolvePreBinding();
|
IBinding b= name.resolvePreBinding();
|
||||||
if (b instanceof IProblemBinding) {
|
if (b instanceof IProblemBinding) {
|
||||||
issues++;
|
issues++;
|
||||||
|
} else if (b instanceof IType && name.getPropertyInParent() == IASTIdExpression.ID_NAME) {
|
||||||
|
// mstodo misused types, should be part of postResolution.
|
||||||
|
IASTNode grand= name.getParent().getParent();
|
||||||
|
if (!(grand instanceof ICPPASTTemplatedTypeTemplateParameter)) {
|
||||||
|
issues++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception t) {
|
} catch (Exception t) {
|
||||||
issues++;
|
issues++;
|
||||||
|
@ -124,6 +141,5 @@ public abstract class ASTAmbiguousNode extends ASTNode {
|
||||||
}
|
}
|
||||||
owner.replace(nodeToReplace, bestAlternative);
|
owner.replace(nodeToReplace, bestAlternative);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to methods on scopes and bindings internal to the parser.
|
* Access to methods on scopes and bindings internal to the parser.
|
||||||
* @since 4.0
|
|
||||||
*/
|
*/
|
||||||
public class ASTInternal {
|
public class ASTInternal {
|
||||||
|
|
||||||
|
@ -70,8 +69,8 @@ public class ASTInternal {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeBinding(IScope scope, IBinding binding) throws DOMException {
|
public static void removeBinding(IScope scope, IBinding binding) throws DOMException {
|
||||||
if (scope instanceof IASTInternalScope) {
|
if (scope instanceof CScope) {
|
||||||
((IASTInternalScope) scope).removeBinding(binding);
|
((CScope) scope).removeBinding(binding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,32 +10,13 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
|
||||||
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.IASTInitializer;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class to search for siblings of an ast node
|
* Utility class to search for siblings of an ast node
|
||||||
*/
|
*/
|
||||||
public class ASTNodeSearch extends ASTVisitor implements ICASTVisitor, ICPPASTVisitor {
|
public class ASTNodeSearch extends ASTGenericVisitor {
|
||||||
private static final int LEFT = 0;
|
private static final int LEFT = 0;
|
||||||
private static final int RIGHT= 1;
|
private static final int RIGHT= 1;
|
||||||
private int fMode;
|
private int fMode;
|
||||||
|
@ -70,7 +51,8 @@ public class ASTNodeSearch extends ASTVisitor implements ICASTVisitor, ICPPASTVi
|
||||||
return fRight;
|
return fRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int process(IASTNode node) {
|
@Override
|
||||||
|
protected int genericVisit(IASTNode node) {
|
||||||
if (node == fParent)
|
if (node == fParent)
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
||||||
|
@ -91,101 +73,4 @@ public class ASTNodeSearch extends ASTVisitor implements ICASTVisitor, ICPPASTVi
|
||||||
}
|
}
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int visit(ICASTDesignator designator) {
|
|
||||||
return process(designator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTArrayModifier arrayModifier) {
|
|
||||||
return process(arrayModifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTDeclaration declaration) {
|
|
||||||
return process(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTDeclarator declarator) {
|
|
||||||
return process(declarator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTDeclSpecifier declSpec) {
|
|
||||||
return process(declSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTEnumerator enumerator) {
|
|
||||||
return process(enumerator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTExpression expression) {
|
|
||||||
return process(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTInitializer initializer) {
|
|
||||||
return process(initializer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTName name) {
|
|
||||||
return process(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTParameterDeclaration parameterDeclaration) {
|
|
||||||
return process(parameterDeclaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTProblem problem) {
|
|
||||||
return process(problem);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTStatement statement) {
|
|
||||||
return process(statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTTranslationUnit tu) {
|
|
||||||
return process(tu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTTypeId typeId) {
|
|
||||||
return process(typeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int visit(ICPPASTBaseSpecifier baseSpecifier) {
|
|
||||||
return process(baseSpecifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
|
||||||
return process(namespaceDefinition);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int visit(ICPPASTTemplateParameter templateParameter) {
|
|
||||||
return process(templateParameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int leave(ICASTDesignator designator) {
|
|
||||||
return PROCESS_CONTINUE;
|
|
||||||
}
|
|
||||||
public int leave(ICPPASTBaseSpecifier baseSpecifier) {
|
|
||||||
return PROCESS_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int leave(ICPPASTNamespaceDefinition namespaceDefinition) {
|
|
||||||
return PROCESS_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int leave(ICPPASTTemplateParameter templateParameter) {
|
|
||||||
return PROCESS_CONTINUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,32 +13,13 @@ package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
|
||||||
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.IASTInitializer;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collector to find all children for an ast-node.
|
* Collector to find all children for an ast-node.
|
||||||
*/
|
*/
|
||||||
class ChildCollector extends ASTVisitor implements ICPPASTVisitor, ICASTVisitor {
|
class ChildCollector extends ASTGenericVisitor {
|
||||||
|
|
||||||
private final IASTNode fNode;
|
private final IASTNode fNode;
|
||||||
private List<IASTNode> fNodes;
|
private List<IASTNode> fNodes;
|
||||||
|
@ -56,7 +37,8 @@ class ChildCollector extends ASTVisitor implements ICPPASTVisitor, ICASTVisitor
|
||||||
return fNodes.toArray(new IASTNode[fNodes.size()]);
|
return fNodes.toArray(new IASTNode[fNodes.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int addChild(IASTNode child) {
|
@Override
|
||||||
|
protected int genericVisit(IASTNode child) {
|
||||||
if (fNodes == null) {
|
if (fNodes == null) {
|
||||||
if (child == fNode)
|
if (child == fNode)
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
@ -65,101 +47,4 @@ class ChildCollector extends ASTVisitor implements ICPPASTVisitor, ICASTVisitor
|
||||||
fNodes.add(child);
|
fNodes.add(child);
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int visit(ICPPASTBaseSpecifier baseSpecifier) {
|
|
||||||
return addChild(baseSpecifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
|
||||||
return addChild(namespaceDefinition);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int visit(ICPPASTTemplateParameter templateParameter) {
|
|
||||||
return addChild(templateParameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTArrayModifier arrayModifier) {
|
|
||||||
return addChild(arrayModifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTDeclaration declaration) {
|
|
||||||
return addChild(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTDeclarator declarator) {
|
|
||||||
return addChild(declarator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTDeclSpecifier declSpec) {
|
|
||||||
return addChild(declSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTEnumerator enumerator) {
|
|
||||||
return addChild(enumerator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTExpression expression) {
|
|
||||||
return addChild(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTInitializer initializer) {
|
|
||||||
return addChild(initializer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTName name) {
|
|
||||||
return addChild(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTParameterDeclaration parameterDeclaration) {
|
|
||||||
return addChild(parameterDeclaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTProblem problem) {
|
|
||||||
return addChild(problem);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTStatement statement) {
|
|
||||||
return addChild(statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTTranslationUnit tu) {
|
|
||||||
return addChild(tu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTTypeId typeId) {
|
|
||||||
return addChild(typeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int visit(ICASTDesignator designator) {
|
|
||||||
return addChild(designator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int leave(ICASTDesignator designator) {
|
|
||||||
return PROCESS_SKIP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int leave(ICPPASTBaseSpecifier baseSpecifier) {
|
|
||||||
return PROCESS_SKIP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int leave(ICPPASTNamespaceDefinition namespaceDefinition) {
|
|
||||||
return PROCESS_SKIP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int leave(ICPPASTTemplateParameter templateParameter) {
|
|
||||||
return PROCESS_SKIP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for methods on scopes that are internal to the AST.
|
* Interface for methods on scopes that are internal to the AST.
|
||||||
* @since 4.0
|
|
||||||
*/
|
*/
|
||||||
public interface IASTInternalScope extends IScope {
|
public interface IASTInternalScope extends IScope {
|
||||||
/**
|
/**
|
||||||
|
@ -41,14 +40,6 @@ public interface IASTInternalScope extends IScope {
|
||||||
*/
|
*/
|
||||||
public void addBinding(IBinding binding) throws DOMException;
|
public void addBinding(IBinding binding) throws DOMException;
|
||||||
|
|
||||||
/**
|
|
||||||
* remove the given binding from this scope
|
|
||||||
*
|
|
||||||
* @param binding
|
|
||||||
* @throws DOMException
|
|
||||||
*/
|
|
||||||
void removeBinding(IBinding binding) throws DOMException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an IASTName to be cached in this scope
|
* Add an IASTName to be cached in this scope
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -41,6 +41,10 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
|
||||||
protected IASTNode node;
|
protected IASTNode node;
|
||||||
private String message = null;
|
private String message = null;
|
||||||
|
|
||||||
|
public ProblemBinding(IASTName name, int id) {
|
||||||
|
this(name, id, null);
|
||||||
|
}
|
||||||
|
|
||||||
public ProblemBinding(IASTNode node, int id, char[] arg) {
|
public ProblemBinding(IASTNode node, int id, char[] arg) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.arg = arg;
|
this.arg = arg;
|
||||||
|
@ -91,6 +95,9 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
|
||||||
|
|
||||||
String msg = (id > 0 && id <= errorMessages.length) ? errorMessages[id - 1] : ""; //$NON-NLS-1$
|
String msg = (id > 0 && id <= errorMessages.length) ? errorMessages[id - 1] : ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (arg == null && node instanceof IASTName)
|
||||||
|
arg= ((IASTName) node).toCharArray();
|
||||||
|
|
||||||
if (arg != null) {
|
if (arg != null) {
|
||||||
msg = MessageFormat.format(msg, new Object[] { new String(arg) });
|
msg = MessageFormat.format(msg, new Object[] { new String(arg) });
|
||||||
}
|
}
|
||||||
|
@ -160,13 +167,6 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
|
||||||
throw new DOMException(this);
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
|
||||||
*/
|
|
||||||
public void removeBinding(IBinding binding) throws DOMException {
|
|
||||||
throw new DOMException(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
|
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
|
||||||
*/
|
*/
|
||||||
|
@ -236,10 +236,10 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setASTNode(IASTNode node, char[] arg) {
|
public void setASTNode(IASTName name) {
|
||||||
if (node != null)
|
if (name != null) {
|
||||||
this.node= node;
|
this.node= name;
|
||||||
if (arg != null)
|
this.arg= null;
|
||||||
this.arg= arg;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2009 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visitor to resolve ast ambiguities in the right order, which is simply a depth
|
||||||
|
* first traversal.
|
||||||
|
*/
|
||||||
|
final class CASTAmbiguityResolver extends ASTVisitor {
|
||||||
|
CASTAmbiguityResolver() {
|
||||||
|
super(false);
|
||||||
|
shouldVisitAmbiguousNodes= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(ASTAmbiguousNode astAmbiguousNode) {
|
||||||
|
astAmbiguousNode.resolveAmbiguity(this);
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -103,7 +103,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
|
||||||
public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
private static final int DEFAULT_POINTEROPS_LIST_SIZE = 4;
|
private static final int DEFAULT_POINTEROPS_LIST_SIZE = 4;
|
||||||
private static final int DEFAULT_PARAMETERS_LIST_SIZE = 4;
|
private static final int DEFAULT_PARAMETERS_LIST_SIZE = 4;
|
||||||
private static final ASTVisitor EMPTY_VISITOR = new ASTVisitor() {};
|
|
||||||
|
|
||||||
private final boolean supportGCCStyleDesignators;
|
private final boolean supportGCCStyleDesignators;
|
||||||
private IIndex index;
|
private IIndex index;
|
||||||
|
@ -1956,7 +1955,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createAmbiguityNodeVisitor() {
|
protected ASTVisitor createAmbiguityNodeVisitor() {
|
||||||
return EMPTY_VISITOR;
|
return new CASTAmbiguityResolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2009 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visitor to resolve ast ambiguities in the right order
|
||||||
|
*/
|
||||||
|
final class CPPASTAmbiguityResolver extends ASTVisitor {
|
||||||
|
private static class ClassContext {
|
||||||
|
ArrayList<IASTNode> fDeferredNodes;
|
||||||
|
final IASTNode fNode;
|
||||||
|
public ClassContext(IASTNode node) {
|
||||||
|
fNode= node;
|
||||||
|
}
|
||||||
|
public void deferNode(IASTNode node) {
|
||||||
|
if (fDeferredNodes == null)
|
||||||
|
fDeferredNodes= new ArrayList<IASTNode>();
|
||||||
|
fDeferredNodes.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private LinkedList<ClassContext> fContextStack;
|
||||||
|
private ClassContext fCurrentContext;
|
||||||
|
private boolean fSkipInitializers;
|
||||||
|
|
||||||
|
CPPASTAmbiguityResolver() {
|
||||||
|
super(false);
|
||||||
|
shouldVisitAmbiguousNodes= true;
|
||||||
|
shouldVisitDeclarations= true;
|
||||||
|
shouldVisitDeclSpecifiers= true;
|
||||||
|
shouldVisitInitializers= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(ASTAmbiguousNode astAmbiguousNode) {
|
||||||
|
astAmbiguousNode.resolveAmbiguity(this);
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTDeclSpecifier declSpec) {
|
||||||
|
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||||
|
if (fCurrentContext != null) {
|
||||||
|
// defer visiting nested classes until the outer class body has been visited.
|
||||||
|
fCurrentContext.deferNode(declSpec);
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
pushContext();
|
||||||
|
fCurrentContext= new ClassContext(declSpec);
|
||||||
|
}
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTDeclSpecifier declSpec) {
|
||||||
|
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||||
|
assert fCurrentContext != null;
|
||||||
|
assert fCurrentContext.fNode == declSpec;
|
||||||
|
if (fCurrentContext != null) {
|
||||||
|
final List<IASTNode> deferredNodes = fCurrentContext.fDeferredNodes;
|
||||||
|
fCurrentContext= null;
|
||||||
|
if (deferredNodes != null) {
|
||||||
|
for (IASTNode node : deferredNodes) {
|
||||||
|
node.accept(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
popContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pushContext() {
|
||||||
|
if (fCurrentContext==null) {
|
||||||
|
if (fContextStack != null && !fContextStack.isEmpty()) {
|
||||||
|
fContextStack.addLast(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (fContextStack == null) {
|
||||||
|
fContextStack= new LinkedList<ClassContext>();
|
||||||
|
}
|
||||||
|
fContextStack.addLast(fCurrentContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void popContext() {
|
||||||
|
if (fContextStack == null || fContextStack.isEmpty()) {
|
||||||
|
fCurrentContext= null;
|
||||||
|
} else {
|
||||||
|
fCurrentContext= fContextStack.removeLast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTDeclaration decl) {
|
||||||
|
if (decl instanceof IASTFunctionDefinition) {
|
||||||
|
final IASTFunctionDefinition fdef= (IASTFunctionDefinition) decl;
|
||||||
|
|
||||||
|
// visit the declarator first, it may contain ambiguous template arguments needed
|
||||||
|
// for associating the template declarations.
|
||||||
|
fSkipInitializers= true;
|
||||||
|
CPPVisitor.findOutermostDeclarator(fdef.getDeclarator()).accept(this);
|
||||||
|
fSkipInitializers= false;
|
||||||
|
|
||||||
|
if (fCurrentContext != null) {
|
||||||
|
// defer visiting the body of the function until the class body has been visited.
|
||||||
|
fdef.getDeclSpecifier().accept(this);
|
||||||
|
fCurrentContext.deferNode(decl);
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTInitializer initializer) {
|
||||||
|
if (fSkipInitializers)
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -41,7 +41,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
|
||||||
|
|
||||||
protected final static class RecursionResolvingBinding extends ProblemBinding {
|
protected final static class RecursionResolvingBinding extends ProblemBinding {
|
||||||
public RecursionResolvingBinding(IASTName node) {
|
public RecursionResolvingBinding(IASTName node) {
|
||||||
super(node, IProblemBinding.SEMANTIC_RECURSION_IN_LOOKUP, node.toCharArray());
|
super(node, IProblemBinding.SEMANTIC_RECURSION_IN_LOOKUP);
|
||||||
Assert.isTrue(sAllowRecursionBindings, getMessage());
|
Assert.isTrue(sAllowRecursionBindings, getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
|
||||||
ProblemBinding pb= (ProblemBinding) b;
|
ProblemBinding pb= (ProblemBinding) b;
|
||||||
final IASTNode node= pb.getASTNode();
|
final IASTNode node= pb.getASTNode();
|
||||||
if (node == null || node.getParent() == null) {
|
if (node == null || node.getParent() == null) {
|
||||||
pb.setASTNode(this, toCharArray());
|
pb.setASTNode(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fBinding= b;
|
fBinding= b;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -382,18 +382,6 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeBinding(IBinding binding) {
|
|
||||||
if (binding instanceof ICPPConstructor) {
|
|
||||||
removeBinding(CONSTRUCTOR_KEY, binding);
|
|
||||||
} else {
|
|
||||||
removeBinding(binding.getNameCharArray(), binding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -31,6 +31,5 @@ public class CPPClassSpecializationScope extends AbstractCPPClassSpecializationS
|
||||||
public void flushCache() {}
|
public void flushCache() {}
|
||||||
public void addName(IASTName name) {}
|
public void addName(IASTName name) {}
|
||||||
public IASTNode getPhysicalNode() { return null; }
|
public IASTNode getPhysicalNode() { return null; }
|
||||||
public void removeBinding(IBinding binding) {}
|
|
||||||
public void addBinding(IBinding binding) {}
|
public void addBinding(IBinding binding) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -293,39 +293,6 @@ abstract public class CPPScope implements ICPPScope, ICPPASTInternalScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
|
||||||
*/
|
|
||||||
public void removeBinding(IBinding binding) {
|
|
||||||
char[] key = binding.getNameCharArray();
|
|
||||||
removeBinding(key, binding);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void removeBinding(char[] key, IBinding binding) {
|
|
||||||
if (bindings == null || ! bindings.containsKey(key))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Object obj = bindings.get(key);
|
|
||||||
if (obj instanceof ObjectSet<?>) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
ObjectSet<Object> set = (ObjectSet<Object>) obj;
|
|
||||||
for (int i = set.size() - 1; i >= 0; i--) {
|
|
||||||
Object o = set.keyAt(i);
|
|
||||||
if ((o instanceof IBinding && o == binding) ||
|
|
||||||
(o instanceof IASTName && ((IASTName)o).getBinding() == binding)) {
|
|
||||||
set.remove(o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (set.isEmpty()) {
|
|
||||||
bindings.remove(key, 0, key.length);
|
|
||||||
}
|
|
||||||
} else if ((obj instanceof IBinding && obj == binding) ||
|
|
||||||
(obj instanceof IASTName && ((IASTName)obj).getBinding() == binding)) {
|
|
||||||
bindings.remove(key, 0, key.length);
|
|
||||||
}
|
|
||||||
isCached = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -250,6 +250,6 @@ public abstract class CPPTemplateParameter extends PlatformObject
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
return new ProblemBinding(getPrimaryDeclaration(), IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray());
|
return new ProblemBinding(getPrimaryDeclaration(), IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -85,22 +85,12 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName)
|
* @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
*/
|
*/
|
||||||
public void addName(IASTName name) {
|
public void addName(IASTName name) {
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
|
||||||
*/
|
|
||||||
public void removeBinding(IBinding binding) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
||||||
return getBinding(name, resolve, IIndexFileSet.EMPTY);
|
return getBinding(name, resolve, IIndexFileSet.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException {
|
|
||||||
return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
|
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
|
||||||
*/
|
*/
|
||||||
|
@ -169,11 +159,19 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) {
|
public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException {
|
||||||
|
return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) {
|
||||||
|
return getBindings(name, resolve, prefixLookup, fileSet, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings, boolean checkPointOfDecl) {
|
||||||
if (prefixLookup)
|
if (prefixLookup)
|
||||||
return IBinding.EMPTY_BINDING_ARRAY;
|
return IBinding.EMPTY_BINDING_ARRAY;
|
||||||
|
|
||||||
return new IBinding[] {getBinding(name, resolve, fileSet)};
|
return new IBinding[] {getBinding(name, resolve, acceptLocalBindings)};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2008 IBM Corporation and others.
|
* Copyright (c) 2002, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -143,7 +143,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
private static final int DEFAULT_PARM_LIST_SIZE = 4;
|
private static final int DEFAULT_PARM_LIST_SIZE = 4;
|
||||||
private static final int DEFAULT_POINTEROPS_LIST_SIZE = 4;
|
private static final int DEFAULT_POINTEROPS_LIST_SIZE = 4;
|
||||||
private static final int DEFAULT_CATCH_HANDLER_LIST_SIZE= 4;
|
private static final int DEFAULT_CATCH_HANDLER_LIST_SIZE= 4;
|
||||||
private static final ASTVisitor EMPTY_VISITOR = new ASTVisitor() {};
|
|
||||||
private static enum DtorStrategy {PREFER_FUNCTION, PREFER_NESTED}
|
private static enum DtorStrategy {PREFER_FUNCTION, PREFER_NESTED}
|
||||||
|
|
||||||
private final boolean allowCPPRestrict;
|
private final boolean allowCPPRestrict;
|
||||||
|
@ -153,7 +152,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
private final IIndex index;
|
private final IIndex index;
|
||||||
protected ICPPASTTranslationUnit translationUnit;
|
protected ICPPASTTranslationUnit translationUnit;
|
||||||
|
|
||||||
private int templateCount = 0;
|
|
||||||
private int functionBodyCount= 0;
|
private int functionBodyCount= 0;
|
||||||
private int rejectLogicalOperatorInTemplateID= 0;
|
private int rejectLogicalOperatorInTemplateID= 0;
|
||||||
private char[] currentClassName;
|
private char[] currentClassName;
|
||||||
|
@ -1418,8 +1416,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* request for a backtrack
|
* request for a backtrack
|
||||||
*/
|
*/
|
||||||
protected IASTDeclaration templateDeclaration(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
protected IASTDeclaration templateDeclaration(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||||
++templateCount;
|
|
||||||
try {
|
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
IToken firstToken = null;
|
IToken firstToken = null;
|
||||||
boolean exported = false;
|
boolean exported = false;
|
||||||
|
@ -1504,11 +1500,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throw bt;
|
throw bt;
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
templateCount--;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* template-parameter-list: template-parameter template-parameter-list ,
|
* template-parameter-list: template-parameter template-parameter-list ,
|
||||||
|
@ -2538,7 +2530,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return dtor1;
|
return dtor1;
|
||||||
|
|
||||||
// optimization outside of function bodies and inside of templates
|
// optimization outside of function bodies and inside of templates
|
||||||
if (functionBodyCount == 0 || templateCount != 0)
|
if (functionBodyCount == 0)
|
||||||
return dtor1;
|
return dtor1;
|
||||||
|
|
||||||
// avoid second option for function definitions
|
// avoid second option for function definitions
|
||||||
|
@ -3692,7 +3684,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createAmbiguityNodeVisitor() {
|
protected ASTVisitor createAmbiguityNodeVisitor() {
|
||||||
return EMPTY_VISITOR;
|
return new CPPASTAmbiguityResolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Google, Inc and others.
|
* Copyright (c) 2008, 2009 Google, Inc and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,18 +7,16 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Sergey Prigogin (Google) - initial API and implementation
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope corresponding to an unknown binding.
|
* Scope corresponding to an unknown binding.
|
||||||
*
|
|
||||||
* @author Sergey Prigogin
|
|
||||||
*/
|
*/
|
||||||
public interface ICPPInternalUnknownScope extends IASTInternalScope {
|
public interface ICPPInternalUnknownScope extends ICPPASTInternalScope {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the binding corresponding to the scope.
|
* @return Returns the binding corresponding to the scope.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -293,7 +293,7 @@ public class CPPSemantics {
|
||||||
node= node.getParent();
|
node= node.getParent();
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.getNameCharArray());
|
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,9 +309,20 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding instanceof ICPPClassType && data.considerConstructors) {
|
if (data.considerConstructors) {
|
||||||
|
ICPPClassType cls= null;
|
||||||
|
// if (binding instanceof ITypedef) {
|
||||||
|
// // mstodo constructor off typedef
|
||||||
|
// IType t= SemanticUtil.getUltimateTypeViaTypedefs((IType) binding);
|
||||||
|
// if (t instanceof ICPPClassType) {
|
||||||
|
// cls= (ICPPClassType) t;
|
||||||
|
// }
|
||||||
|
// } else
|
||||||
|
if (binding instanceof ICPPClassType) {
|
||||||
|
cls= (ICPPClassType) binding;
|
||||||
|
}
|
||||||
|
if (cls != null) {
|
||||||
try {
|
try {
|
||||||
ICPPClassType cls = (ICPPClassType) binding;
|
|
||||||
if (data.astName instanceof ICPPASTTemplateId && cls instanceof ICPPClassTemplate) {
|
if (data.astName instanceof ICPPASTTemplateId && cls instanceof ICPPClassTemplate) {
|
||||||
if (data.tu != null) {
|
if (data.tu != null) {
|
||||||
ICPPASTTemplateId id = (ICPPASTTemplateId) data.astName;
|
ICPPASTTemplateId id = (ICPPASTTemplateId) data.astName;
|
||||||
|
@ -335,6 +346,7 @@ public class CPPSemantics {
|
||||||
binding = e.getProblem();
|
binding = e.getProblem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IASTName name= data.astName;
|
IASTName name= data.astName;
|
||||||
IASTNode nameParent= name.getParent();
|
IASTNode nameParent= name.getParent();
|
||||||
|
@ -356,11 +368,12 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the lookup in base-classes ran into a deferred instance, use the computed unknown binding.
|
// if the lookup in base-classes ran into a deferred instance, use the computed unknown binding.
|
||||||
|
final ASTNodeProperty namePropertyInParent = name.getPropertyInParent();
|
||||||
if (binding == null && data.skippedScope != null) {
|
if (binding == null && data.skippedScope != null) {
|
||||||
if (data.functionParameters != null) {
|
if (data.functionParameters != null) {
|
||||||
binding= new CPPUnknownFunction(data.skippedScope, name.getLastName());
|
binding= new CPPUnknownFunction(data.skippedScope, name.getLastName());
|
||||||
} else {
|
} else {
|
||||||
if (name.getPropertyInParent() == IASTNamedTypeSpecifier.NAME) {
|
if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) {
|
||||||
binding= new CPPUnknownClass(data.skippedScope, name.getLastName());
|
binding= new CPPUnknownClass(data.skippedScope, name.getLastName());
|
||||||
} else {
|
} else {
|
||||||
binding= new CPPUnknownBinding(data.skippedScope, name.getLastName());
|
binding= new CPPUnknownBinding(data.skippedScope, name.getLastName());
|
||||||
|
@ -368,19 +381,31 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding != null) {
|
if (binding != null && !(binding instanceof IProblemBinding)) {
|
||||||
if (name.getPropertyInParent() == IASTNamedTypeSpecifier.NAME && !(binding instanceof IType || binding instanceof ICPPConstructor)) {
|
if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) {
|
||||||
|
if (!(binding instanceof IType || binding instanceof ICPPConstructor)) {
|
||||||
IASTNode parent = name.getParent().getParent();
|
IASTNode parent = name.getParent().getParent();
|
||||||
if (parent instanceof IASTTypeId && parent.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
|
if (parent instanceof IASTTypeId && parent.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
|
||||||
if (!(binding instanceof IType)) {
|
if (!(binding instanceof IType)) {
|
||||||
// a type id needs to hold a type
|
// a type id needs to hold a type
|
||||||
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.getNameCharArray());
|
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||||
}
|
}
|
||||||
// don't create a problem here
|
// don't create a problem here
|
||||||
} else {
|
} else {
|
||||||
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.getNameCharArray());
|
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// mstodo misused types, important for ambiguity resolution.
|
||||||
|
// } else if (namePropertyInParent == IASTIdExpression.ID_NAME) {
|
||||||
|
// if (binding instanceof IType) {
|
||||||
|
// IASTNode parent= name.getParent().getParent();
|
||||||
|
// if (parent instanceof ICPPASTTemplatedTypeTemplateParameter) {
|
||||||
|
// // default for template template parameter is an id-expression, which is a type.
|
||||||
|
// } else {
|
||||||
|
// binding= new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding != null && !(binding instanceof IProblemBinding)) {
|
if (binding != null && !(binding instanceof IProblemBinding)) {
|
||||||
|
@ -391,9 +416,9 @@ public class CPPSemantics {
|
||||||
// If we're still null...
|
// If we're still null...
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
if (name instanceof ICPPASTQualifiedName && data.forFunctionDeclaration())
|
if (name instanceof ICPPASTQualifiedName && data.forFunctionDeclaration())
|
||||||
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND, data.getNameCharArray());
|
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND);
|
||||||
else
|
else
|
||||||
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, data.getNameCharArray());
|
binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||||
}
|
}
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
@ -919,14 +944,14 @@ public class CPPSemantics {
|
||||||
for (int j = 0; j < r.length && r[j] != null; j++) {
|
for (int j = 0; j < r.length && r[j] != null; j++) {
|
||||||
if (checkForAmbiguity(data, r[j], inherited)) {
|
if (checkForAmbiguity(data, r[j], inherited)) {
|
||||||
data.problem = new ProblemBinding(data.astName,
|
data.problem = new ProblemBinding(data.astName,
|
||||||
IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getNameCharArray());
|
IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (checkForAmbiguity(data, result, inherited)) {
|
if (checkForAmbiguity(data, result, inherited)) {
|
||||||
data.problem = new ProblemBinding(data.astName,
|
data.problem = new ProblemBinding(data.astName,
|
||||||
IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getNameCharArray());
|
IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1825,7 +1850,7 @@ public class CPPSemantics {
|
||||||
if (i1)
|
if (i1)
|
||||||
type= temp;
|
type= temp;
|
||||||
} else {
|
} else {
|
||||||
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getNameCharArray());
|
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1842,7 +1867,7 @@ public class CPPSemantics {
|
||||||
if (ibobj)
|
if (ibobj)
|
||||||
obj= temp;
|
obj= temp;
|
||||||
} else {
|
} else {
|
||||||
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getNameCharArray());
|
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1850,7 +1875,7 @@ public class CPPSemantics {
|
||||||
if (data.forUsingDeclaration()) {
|
if (data.forUsingDeclaration()) {
|
||||||
IBinding[] bindings = null;
|
IBinding[] bindings = null;
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
if (fns.size() > 0) return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getNameCharArray());
|
if (fns.size() > 0) return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
// if (type == null) return obj;
|
// if (type == null) return obj;
|
||||||
bindings = (IBinding[]) ArrayUtil.append(IBinding.class, bindings, obj);
|
bindings = (IBinding[]) ArrayUtil.append(IBinding.class, bindings, obj);
|
||||||
bindings = (IBinding[]) ArrayUtil.append(IBinding.class, bindings, type);
|
bindings = (IBinding[]) ArrayUtil.append(IBinding.class, bindings, type);
|
||||||
|
@ -1890,7 +1915,7 @@ public class CPPSemantics {
|
||||||
|
|
||||||
if (numFns > 0) {
|
if (numFns > 0) {
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getNameCharArray());
|
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
return resolveFunction(data, fns.keyArray(IFunction.class));
|
return resolveFunction(data, fns.keyArray(IFunction.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2225,7 +2250,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambiguous || bestHasAmbiguousParam) {
|
if (ambiguous || bestHasAmbiguousParam) {
|
||||||
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getNameCharArray());
|
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bestFn;
|
return bestFn;
|
||||||
|
@ -2234,7 +2259,7 @@ public class CPPSemantics {
|
||||||
private static IBinding resolveUserDefinedConversion(ICPPASTConversionName astName, IFunction[] fns) {
|
private static IBinding resolveUserDefinedConversion(ICPPASTConversionName astName, IFunction[] fns) {
|
||||||
IType t= CPPVisitor.createType(astName.getTypeId());
|
IType t= CPPVisitor.createType(astName.getTypeId());
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE, astName.toCharArray());
|
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||||
}
|
}
|
||||||
for (IFunction function : fns) {
|
for (IFunction function : fns) {
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
|
@ -2247,7 +2272,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, astName.toCharArray());
|
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICPPFunctionTemplate asTemplate(IFunction function) {
|
private static ICPPFunctionTemplate asTemplate(IFunction function) {
|
||||||
|
@ -2289,7 +2314,7 @@ public class CPPSemantics {
|
||||||
while (type != null) {
|
while (type != null) {
|
||||||
type = getUltimateType(type, false);
|
type = getUltimateType(type, false);
|
||||||
if (type == null || !(type instanceof IFunctionType))
|
if (type == null || !(type instanceof IFunctionType))
|
||||||
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getNameCharArray());
|
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
|
|
||||||
for (IBinding fn2 : fns) {
|
for (IBinding fn2 : fns) {
|
||||||
IFunction fn = (IFunction) fn2;
|
IFunction fn = (IFunction) fn2;
|
||||||
|
@ -2301,8 +2326,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
if (type.isSameType(ft)) {
|
if (type.isSameType(ft)) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP,
|
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
data.getNameCharArray());
|
|
||||||
}
|
}
|
||||||
result = fn;
|
result = fn;
|
||||||
}
|
}
|
||||||
|
@ -2315,9 +2339,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result != null ?
|
return result != null ? result : new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||||
result :
|
|
||||||
new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getNameCharArray());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object getTargetType(LookupData data) {
|
private static Object getTargetType(LookupData data) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -1284,7 +1284,7 @@ public class CPPTemplates {
|
||||||
IASTNode param= params[i];
|
IASTNode param= params[i];
|
||||||
IType type= CPPVisitor.createType(param);
|
IType type= CPPVisitor.createType(param);
|
||||||
if (type == null)
|
if (type == null)
|
||||||
throw new DOMException(new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TYPE, id.toCharArray()));
|
throw new DOMException(new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TYPE));
|
||||||
|
|
||||||
if (param instanceof IASTExpression) {
|
if (param instanceof IASTExpression) {
|
||||||
IValue value= Value.create((IASTExpression) param, Value.MAX_RECURSION_DEPTH);
|
IValue value= Value.create((IASTExpression) param, Value.MAX_RECURSION_DEPTH);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -415,8 +415,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
if ((binding instanceof ICPPClassTemplate) == template) {
|
if ((binding instanceof ICPPClassTemplate) == template) {
|
||||||
((ICPPInternalBinding) binding).addDeclaration(elabType);
|
((ICPPInternalBinding) binding).addDeclaration(elabType);
|
||||||
} else {
|
} else {
|
||||||
binding = new ProblemBinding(name,
|
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
||||||
IProblemBinding.SEMANTIC_INVALID_REDECLARATION, name.toCharArray());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
|
@ -461,8 +460,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
(binding instanceof ICPPClassTemplate) == template) {
|
(binding instanceof ICPPClassTemplate) == template) {
|
||||||
internal.addDefinition(compType);
|
internal.addDefinition(compType);
|
||||||
} else {
|
} else {
|
||||||
binding = new ProblemBinding(name,
|
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
|
||||||
IProblemBinding.SEMANTIC_INVALID_REDEFINITION, name.toCharArray());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
|
@ -505,8 +503,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
binding = new CPPNamespaceAlias(alias.getAlias(), (ICPPNamespace) namespace);
|
binding = new CPPNamespaceAlias(alias.getAlias(), (ICPPNamespace) namespace);
|
||||||
ASTInternal.addName(scope, alias.getAlias());
|
ASTInternal.addName(scope, alias.getAlias());
|
||||||
} else {
|
} else {
|
||||||
binding = new ProblemBinding(alias.getAlias(),
|
binding = new ProblemBinding(alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||||
IProblemBinding.SEMANTIC_NAME_NOT_FOUND, alias.getAlias().toCharArray());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
|
@ -628,7 +625,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
} catch (DOMException e1) {
|
} catch (DOMException e1) {
|
||||||
return e1.getProblem();
|
return e1.getProblem();
|
||||||
}
|
}
|
||||||
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION, name.toCharArray());
|
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
||||||
}
|
}
|
||||||
// if we don't resolve the target type first, we get a problem binding in case the typedef
|
// if we don't resolve the target type first, we get a problem binding in case the typedef
|
||||||
// redeclares the target type:
|
// redeclares the target type:
|
||||||
|
@ -651,8 +648,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
if (def instanceof IASTDeclarator)
|
if (def instanceof IASTDeclarator)
|
||||||
def = ((IASTDeclarator)def).getName();
|
def = ((IASTDeclarator)def).getName();
|
||||||
if (def != name) {
|
if (def != name) {
|
||||||
return new ProblemBinding(name,
|
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
|
||||||
IProblemBinding.SEMANTIC_INVALID_REDEFINITION, name.toCharArray());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,7 +682,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
if (binding instanceof ICPPInternalBinding)
|
if (binding instanceof ICPPInternalBinding)
|
||||||
((ICPPInternalBinding) binding).addDeclaration(name);
|
((ICPPInternalBinding) binding).addDeclaration(name);
|
||||||
} else {
|
} else {
|
||||||
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION, declarator.getName().toCharArray());
|
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
||||||
}
|
}
|
||||||
} else if (simpleDecl != null && simpleDecl.getParent() instanceof ICPPASTCompositeTypeSpecifier) {
|
} else if (simpleDecl != null && simpleDecl.getParent() instanceof ICPPASTCompositeTypeSpecifier) {
|
||||||
binding = new CPPField(name);
|
binding = new CPPField(name);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -18,7 +18,27 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.*;
|
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.IASTBinaryExpression;
|
||||||
|
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.IASTInitializer;
|
||||||
|
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.c.ICASTFieldDesignator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
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.ICPPASTConstructorChainInitializer;
|
||||||
|
@ -273,19 +293,29 @@ public class LookupData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkWholeClassScope(IASTName name) {
|
public static boolean checkWholeClassScope(IASTName name) {
|
||||||
if (name == null) return false;
|
if (name == null)
|
||||||
if (name.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return true;
|
return false;
|
||||||
|
|
||||||
|
ASTNodeProperty lastProp= name.getPropertyInParent();
|
||||||
|
if (lastProp == CPPSemantics.STRING_LOOKUP_PROPERTY)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
boolean inInitializer= false;
|
||||||
IASTNode parent = name.getParent();
|
IASTNode parent = name.getParent();
|
||||||
while (parent != null && !(parent instanceof IASTFunctionDefinition)) {
|
while (parent != null && !(parent instanceof IASTFunctionDefinition)) {
|
||||||
ASTNodeProperty prop = parent.getPropertyInParent();
|
if (parent instanceof IASTInitializer) {
|
||||||
if (prop == IASTParameterDeclaration.DECL_SPECIFIER ||
|
inInitializer= true;
|
||||||
prop == IASTFunctionDefinition.DECL_SPECIFIER) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
lastProp= parent.getPropertyInParent();
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
}
|
}
|
||||||
if (parent instanceof IASTFunctionDefinition) {
|
if (parent instanceof IASTFunctionDefinition) {
|
||||||
|
if (lastProp == IASTFunctionDefinition.DECL_SPECIFIER ||
|
||||||
|
lastProp == IASTFunctionDefinition.DECLARATOR) {
|
||||||
|
if (!inInitializer)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
while (parent.getParent() instanceof ICPPASTTemplateDeclaration)
|
while (parent.getParent() instanceof ICPPASTTemplateDeclaration)
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
if (parent.getPropertyInParent() != IASTCompositeTypeSpecifier.MEMBER_DECLARATION)
|
if (parent.getPropertyInParent() != IASTCompositeTypeSpecifier.MEMBER_DECLARATION)
|
||||||
|
|
Loading…
Add table
Reference in a new issue