mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-17 05:05:43 +02:00
- Modify CVisitor.visit* to enable better control over visiting the AST.
- Merge ClearBindingAction & ClearBindingFromScopeAction - Modify CollectDeclarationsAction to avoid creating bindings as much as possible
This commit is contained in:
parent
e7ebb3a57a
commit
0988982be3
5 changed files with 175 additions and 120 deletions
|
@ -67,16 +67,19 @@ public class AST2BaseTest extends TestCase {
|
||||||
private static final IParserLogService NULL_LOG = new NullLogService();
|
private static final IParserLogService NULL_LOG = new NullLogService();
|
||||||
|
|
||||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang ) throws ParserException {
|
protected IASTTranslationUnit parse( String code, ParserLanguage lang ) throws ParserException {
|
||||||
return parse(code, lang, false);
|
return parse(code, lang, false, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions ) throws ParserException {
|
||||||
|
return parse( code, lang, useGNUExtensions, true );
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @param c
|
* @param c
|
||||||
* @return
|
* @return
|
||||||
* @throws ParserException
|
* @throws ParserException
|
||||||
*/
|
*/
|
||||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions ) throws ParserException {
|
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
|
||||||
CodeReader codeReader = new CodeReader(code
|
CodeReader codeReader = new CodeReader(code
|
||||||
.toCharArray());
|
.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
|
@ -117,12 +120,12 @@ public class AST2BaseTest extends TestCase {
|
||||||
if( parser2.encounteredError() )
|
if( parser2.encounteredError() )
|
||||||
throw new ParserException( "FAILURE"); //$NON-NLS-1$
|
throw new ParserException( "FAILURE"); //$NON-NLS-1$
|
||||||
|
|
||||||
if( lang == ParserLanguage.C )
|
if( lang == ParserLanguage.C && expectNoProblems )
|
||||||
{
|
{
|
||||||
IASTProblem [] problems = CVisitor.getProblems(tu);
|
IASTProblem [] problems = CVisitor.getProblems(tu);
|
||||||
assertEquals( problems.length, 0 );
|
assertEquals( problems.length, 0 );
|
||||||
}
|
}
|
||||||
else if ( lang == ParserLanguage.CPP )
|
else if ( lang == ParserLanguage.CPP && expectNoProblems )
|
||||||
{
|
{
|
||||||
IASTProblem [] problems = CPPVisitor.getProblems(tu);
|
IASTProblem [] problems = CPPVisitor.getProblems(tu);
|
||||||
assertEquals( problems.length, 0 );
|
assertEquals( problems.length, 0 );
|
||||||
|
@ -225,9 +228,9 @@ public class AST2BaseTest extends TestCase {
|
||||||
processNames = true;
|
processNames = true;
|
||||||
}
|
}
|
||||||
public List nameList = new ArrayList();
|
public List nameList = new ArrayList();
|
||||||
public boolean processName( IASTName name ){
|
public int processName( IASTName name ){
|
||||||
nameList.add( name );
|
nameList.add( name );
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
public IASTName getName( int idx ){
|
public IASTName getName( int idx ){
|
||||||
if( idx < 0 || idx >= nameList.size() )
|
if( idx < 0 || idx >= nameList.size() )
|
||||||
|
|
|
@ -262,7 +262,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$
|
||||||
buffer.append( "int f(x) char\n" ); //$NON-NLS-1$
|
buffer.append( "int f(x) char\n" ); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
||||||
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
||||||
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
||||||
|
@ -293,7 +293,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
buffer.append( "int i=0;\n" ); //$NON-NLS-1$
|
buffer.append( "int i=0;\n" ); //$NON-NLS-1$
|
||||||
buffer.append( "int f(x) i++;\n" ); //$NON-NLS-1$
|
buffer.append( "int f(x) i++;\n" ); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
||||||
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[1];
|
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[1];
|
||||||
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
||||||
|
@ -324,7 +324,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$
|
||||||
buffer.append( "int f(x) char y;\n" ); //$NON-NLS-1$
|
buffer.append( "int f(x) char y;\n" ); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
||||||
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
||||||
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
||||||
|
@ -349,7 +349,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$
|
||||||
buffer.append( "int f(x,y,z) char x,y,z; int a;\n" ); //$NON-NLS-1$
|
buffer.append( "int f(x,y,z) char x,y,z; int a;\n" ); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
||||||
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
||||||
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
||||||
|
@ -399,7 +399,7 @@ public class AST2KnRTests extends AST2BaseTest {
|
||||||
StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$
|
||||||
buffer.append( "int f(x) char x,a;\n" ); //$NON-NLS-1$
|
buffer.append( "int f(x) char x,a;\n" ); //$NON-NLS-1$
|
||||||
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
buffer.append( "{ return x == 0; }\n" ); //$NON-NLS-1$
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true );
|
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C, true, false );
|
||||||
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
IASTFunctionDefinition f = (IASTFunctionDefinition)tu.getDeclarations()[0];
|
||||||
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
assertTrue(f.getDeclarator() instanceof ICASTKnRFunctionDeclarator);
|
||||||
|
|
|
@ -287,7 +287,7 @@ public class GCCTests extends AST2BaseTest {
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
CVisitor.visitTranslationUnit( tu, collector );
|
CVisitor.visitTranslationUnit( tu, collector );
|
||||||
|
|
||||||
assertEquals( collector.size(), 9 );
|
assertEquals( collector.size(), 7 );
|
||||||
IVariable winds = (IVariable) collector.getName( 1 ).resolveBinding();
|
IVariable winds = (IVariable) collector.getName( 1 ).resolveBinding();
|
||||||
|
|
||||||
assertInstances( collector, winds, 6 );
|
assertInstances( collector, winds, 6 );
|
||||||
|
@ -313,7 +313,7 @@ public class GCCTests extends AST2BaseTest {
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
CVisitor.visitTranslationUnit( tu, collector );
|
CVisitor.visitTranslationUnit( tu, collector );
|
||||||
|
|
||||||
assertEquals( collector.size(), 16 );
|
assertEquals( collector.size(), 15 );
|
||||||
ITypedef uint64 = (ITypedef) collector.getName( 0 ).resolveBinding();
|
ITypedef uint64 = (ITypedef) collector.getName( 0 ).resolveBinding();
|
||||||
IVariable bigconst = (IVariable) collector.getName( 2 ).resolveBinding();
|
IVariable bigconst = (IVariable) collector.getName( 2 ).resolveBinding();
|
||||||
IVariable a = (IVariable) collector.getName( 3 ).resolveBinding();
|
IVariable a = (IVariable) collector.getName( 3 ).resolveBinding();
|
||||||
|
@ -351,7 +351,7 @@ public class GCCTests extends AST2BaseTest {
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
CVisitor.visitTranslationUnit( tu, collector );
|
CVisitor.visitTranslationUnit( tu, collector );
|
||||||
|
|
||||||
assertEquals( collector.size(), 37 );
|
assertEquals( collector.size(), 34 );
|
||||||
IVariable aa = (IVariable) collector.getName( 0 ).resolveBinding();
|
IVariable aa = (IVariable) collector.getName( 0 ).resolveBinding();
|
||||||
IVariable bb = (IVariable) collector.getName( 1 ).resolveBinding();
|
IVariable bb = (IVariable) collector.getName( 1 ).resolveBinding();
|
||||||
IFunction seqgt = (IFunction) collector.getName( 2 ).resolveBinding();
|
IFunction seqgt = (IFunction) collector.getName( 2 ).resolveBinding();
|
||||||
|
@ -422,7 +422,7 @@ public class GCCTests extends AST2BaseTest {
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
CVisitor.visitTranslationUnit( tu, collector );
|
CVisitor.visitTranslationUnit( tu, collector );
|
||||||
|
|
||||||
assertEquals( collector.size(), 15 );
|
assertEquals( collector.size(), 14 );
|
||||||
IFunction f = (IFunction) collector.getName( 0 ).resolveBinding();
|
IFunction f = (IFunction) collector.getName( 0 ).resolveBinding();
|
||||||
IParameter a = (IParameter) collector.getName( 1 ).resolveBinding();
|
IParameter a = (IParameter) collector.getName( 1 ).resolveBinding();
|
||||||
IParameter y = (IParameter) collector.getName( 2 ).resolveBinding();
|
IParameter y = (IParameter) collector.getName( 2 ).resolveBinding();
|
||||||
|
@ -624,7 +624,7 @@ public class GCCTests extends AST2BaseTest {
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
CVisitor.visitTranslationUnit( tu, collector );
|
CVisitor.visitTranslationUnit( tu, collector );
|
||||||
|
|
||||||
assertEquals( collector.size(), 7 );
|
assertEquals( collector.size(), 6 );
|
||||||
IFunction sub = (IFunction) collector.getName( 0 ).resolveBinding();
|
IFunction sub = (IFunction) collector.getName( 0 ).resolveBinding();
|
||||||
IParameter a = (IParameter) collector.getName( 1 ).resolveBinding();
|
IParameter a = (IParameter) collector.getName( 1 ).resolveBinding();
|
||||||
|
|
||||||
|
@ -706,7 +706,7 @@ public class GCCTests extends AST2BaseTest {
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
CVisitor.visitTranslationUnit( tu, collector );
|
CVisitor.visitTranslationUnit( tu, collector );
|
||||||
|
|
||||||
assertEquals( collector.size(), 23 );
|
assertEquals( collector.size(), 22 );
|
||||||
ICompositeType s1 = (ICompositeType) collector.getName( 0 ).resolveBinding();
|
ICompositeType s1 = (ICompositeType) collector.getName( 0 ).resolveBinding();
|
||||||
IField d1 = (IField) collector.getName( 1 ).resolveBinding();
|
IField d1 = (IField) collector.getName( 1 ).resolveBinding();
|
||||||
ICompositeType s2 = (ICompositeType) collector.getName( 2 ).resolveBinding();
|
ICompositeType s2 = (ICompositeType) collector.getName( 2 ).resolveBinding();
|
||||||
|
@ -744,15 +744,15 @@ public class GCCTests extends AST2BaseTest {
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
CVisitor.visitTranslationUnit( tu, collector );
|
CVisitor.visitTranslationUnit( tu, collector );
|
||||||
|
|
||||||
assertEquals( collector.size(), 28 );
|
assertEquals( collector.size(), 27 );
|
||||||
ICompositeType F = (ICompositeType) collector.getName( 0 ).resolveBinding();
|
ICompositeType F = (ICompositeType) collector.getName( 0 ).resolveBinding();
|
||||||
IField i = (IField) collector.getName( 1 ).resolveBinding();
|
IField i = (IField) collector.getName( 1 ).resolveBinding();
|
||||||
IFunction f1 = (IFunction) collector.getName( 2 ).resolveBinding();
|
IFunction f1 = (IFunction) collector.getName( 2 ).resolveBinding();
|
||||||
IParameter px = (IParameter) collector.getName( 4 ).resolveBinding();
|
IParameter px = (IParameter) collector.getName( 4 ).resolveBinding();
|
||||||
IParameter py = (IParameter) collector.getName( 6 ).resolveBinding();
|
IParameter py = (IParameter) collector.getName( 6 ).resolveBinding();
|
||||||
IVariable timeout = (IVariable) collector.getName( 7 ).resolveBinding();
|
IVariable timeout = (IVariable) collector.getName( 7 ).resolveBinding();
|
||||||
IVariable x = (IVariable) collector.getName( 20 ).resolveBinding();
|
IVariable x = (IVariable) collector.getName( 18 ).resolveBinding();
|
||||||
IVariable y = (IVariable) collector.getName( 21 ).resolveBinding();
|
IVariable y = (IVariable) collector.getName( 19 ).resolveBinding();
|
||||||
|
|
||||||
assertInstances( collector, F, 5 );
|
assertInstances( collector, F, 5 );
|
||||||
assertInstances( collector, i, 6 );
|
assertInstances( collector, i, 6 );
|
||||||
|
|
|
@ -100,17 +100,16 @@ public class CFunctionScope implements ICFunctionScope {
|
||||||
|
|
||||||
static private class FindLabelsAction extends CBaseVisitorAction {
|
static private class FindLabelsAction extends CBaseVisitorAction {
|
||||||
public List labels = new ArrayList();
|
public List labels = new ArrayList();
|
||||||
public boolean ambiguous = false;
|
|
||||||
|
|
||||||
public FindLabelsAction(){
|
public FindLabelsAction(){
|
||||||
processStatements = true;
|
processStatements = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean processStatement( IASTStatement statement ) {
|
public int processStatement( IASTStatement statement ) {
|
||||||
if( statement instanceof IASTLabelStatement ){
|
if( statement instanceof IASTLabelStatement ){
|
||||||
labels.add( statement );
|
labels.add( statement );
|
||||||
}
|
}
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created on Nov 5, 2004
|
* Created on Nov 5, 2004
|
||||||
|
@ -109,27 +110,37 @@ public class CVisitor {
|
||||||
public boolean processEnumerators = false;
|
public boolean processEnumerators = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true to continue visiting, return false to stop
|
* @return true to continue visiting, abort to stop, skip to not descend into this node.
|
||||||
*/
|
*/
|
||||||
public boolean processName( IASTName name ) { return true; }
|
public final static int PROCESS_SKIP = 1;
|
||||||
public boolean processDeclaration( IASTDeclaration declaration ){ return true; }
|
public final static int PROCESS_ABORT = 2;
|
||||||
public boolean processInitializer( IASTInitializer initializer ){ return true; }
|
public final static int PROCESS_CONTINUE = 3;
|
||||||
public boolean processParameterDeclaration( IASTParameterDeclaration parameterDeclaration ) { return true; }
|
|
||||||
public boolean processDeclarator( IASTDeclarator declarator ) { return true; }
|
public int processName( IASTName name ) { return PROCESS_CONTINUE; }
|
||||||
public boolean processDeclSpecifier( IASTDeclSpecifier declSpec ){return true; }
|
public int processDeclaration( IASTDeclaration declaration ){ return PROCESS_CONTINUE; }
|
||||||
public boolean processExpression( IASTExpression expression ) { return true; }
|
public int processInitializer( IASTInitializer initializer ){ return PROCESS_CONTINUE; }
|
||||||
public boolean processStatement( IASTStatement statement ) { return true; }
|
public int processParameterDeclaration( IASTParameterDeclaration parameterDeclaration ) { return PROCESS_CONTINUE; }
|
||||||
public boolean processTypeId( IASTTypeId typeId ) { return true; }
|
public int processDeclarator( IASTDeclarator declarator ) { return PROCESS_CONTINUE; }
|
||||||
public boolean processEnumerator( IASTEnumerator enumerator ) { return true; }
|
public int processDeclSpecifier( IASTDeclSpecifier declSpec ){return PROCESS_CONTINUE; }
|
||||||
|
public int processExpression( IASTExpression expression ) { return PROCESS_CONTINUE; }
|
||||||
|
public int processStatement( IASTStatement statement ) { return PROCESS_CONTINUE; }
|
||||||
|
public int processTypeId( IASTTypeId typeId ) { return PROCESS_CONTINUE; }
|
||||||
|
public int processEnumerator( IASTEnumerator enumerator ) { return PROCESS_CONTINUE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ClearBindingAction extends CBaseVisitorAction {
|
public static class ClearBindingAction extends CBaseVisitorAction {
|
||||||
{
|
{
|
||||||
processNames = true;
|
processNames = true;
|
||||||
}
|
}
|
||||||
public boolean processName(IASTName name) {
|
public int processName(IASTName name) {
|
||||||
((CASTName) name ).setBinding( null );
|
if ( ((CASTName)name).hasBinding() ) {
|
||||||
return true;
|
ICScope scope = (ICScope)name.resolveBinding().getScope();
|
||||||
|
if ( scope != null )
|
||||||
|
scope.removeBinding(name.resolveBinding());
|
||||||
|
((CASTName) name ).setBinding( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,55 +192,41 @@ public class CVisitor {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDeclaration(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDeclaration(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||||
*/
|
*/
|
||||||
public boolean processDeclaration(IASTDeclaration declaration) {
|
public int processDeclaration(IASTDeclaration declaration) {
|
||||||
if ( declaration instanceof IASTProblemHolder )
|
if ( declaration instanceof IASTProblemHolder )
|
||||||
addProblem(((IASTProblemHolder)declaration).getProblem());
|
addProblem(((IASTProblemHolder)declaration).getProblem());
|
||||||
|
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
*/
|
*/
|
||||||
public boolean processExpression(IASTExpression expression) {
|
public int processExpression(IASTExpression expression) {
|
||||||
if ( expression instanceof IASTProblemHolder )
|
if ( expression instanceof IASTProblemHolder )
|
||||||
addProblem(((IASTProblemHolder)expression).getProblem());
|
addProblem(((IASTProblemHolder)expression).getProblem());
|
||||||
|
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processStatement(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processStatement(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
*/
|
*/
|
||||||
public boolean processStatement(IASTStatement statement) {
|
public int processStatement(IASTStatement statement) {
|
||||||
if ( statement instanceof IASTProblemHolder )
|
if ( statement instanceof IASTProblemHolder )
|
||||||
addProblem(((IASTProblemHolder)statement).getProblem());
|
addProblem(((IASTProblemHolder)statement).getProblem());
|
||||||
|
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||||
*/
|
*/
|
||||||
public boolean processTypeId(IASTTypeId typeId) {
|
public int processTypeId(IASTTypeId typeId) {
|
||||||
if ( typeId instanceof IASTProblemHolder )
|
if ( typeId instanceof IASTProblemHolder )
|
||||||
addProblem(((IASTProblemHolder)typeId).getProblem());
|
addProblem(((IASTProblemHolder)typeId).getProblem());
|
||||||
|
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ClearBindingFromScopeAction extends CBaseVisitorAction {
|
|
||||||
{
|
|
||||||
processNames = true;
|
|
||||||
}
|
|
||||||
public boolean processName(IASTName name) {
|
|
||||||
if ( ((CASTName)name).hasBinding() ) {
|
|
||||||
ICScope scope = (ICScope)name.resolveBinding().getScope();
|
|
||||||
if ( scope != null )
|
|
||||||
scope.removeBinding(name.resolveBinding());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,8 +282,14 @@ public class CVisitor {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDeclarator(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
|
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDeclarator(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
|
||||||
*/
|
*/
|
||||||
public boolean processDeclarator(IASTDeclarator declarator) {
|
public int processDeclarator(IASTDeclarator declarator) {
|
||||||
if ( declarator == null ) return true;
|
//GCC allows declarations in expressions, so we have to continue from the
|
||||||
|
//declarator in case there is something in the initializer expression
|
||||||
|
if ( declarator == null ) return PROCESS_CONTINUE;
|
||||||
|
|
||||||
|
//if the binding is something not declared in a declarator, continue
|
||||||
|
if( binding instanceof ICompositeType ) return PROCESS_CONTINUE;
|
||||||
|
if( binding instanceof IEnumeration ) return PROCESS_CONTINUE;
|
||||||
|
|
||||||
IASTNode parent = declarator.getParent();
|
IASTNode parent = declarator.getParent();
|
||||||
while (parent != null && !(parent instanceof IASTDeclaration))
|
while (parent != null && !(parent instanceof IASTDeclaration))
|
||||||
|
@ -300,8 +303,8 @@ public class CVisitor {
|
||||||
}
|
}
|
||||||
} else if ( parent instanceof IASTSimpleDeclaration ) {
|
} else if ( parent instanceof IASTSimpleDeclaration ) {
|
||||||
// prototype parameter with no identifier isn't a declaration of the K&R C parameter
|
// prototype parameter with no identifier isn't a declaration of the K&R C parameter
|
||||||
if ( binding instanceof CKnRParameter && declarator.getName().toString() == null)
|
if ( binding instanceof CKnRParameter && declarator.getName().toCharArray().length == 0 )
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
|
|
||||||
if ( (declarator.getName() != null && declarator.getName().resolveBinding() == binding) ) {
|
if ( (declarator.getName() != null && declarator.getName().resolveBinding() == binding) ) {
|
||||||
if ( declarator instanceof IASTStandardFunctionDeclarator ||
|
if ( declarator instanceof IASTStandardFunctionDeclarator ||
|
||||||
|
@ -311,22 +314,26 @@ public class CVisitor {
|
||||||
|
|
||||||
addName(declarator.getName());
|
addName(declarator.getName());
|
||||||
}
|
}
|
||||||
} else if ( parent instanceof IASTParameterDeclaration ) {
|
}
|
||||||
if ( declarator.getName() != null && declarator.getName().resolveBinding() == binding ) {
|
} else if ( parent instanceof IASTParameterDeclaration && binding instanceof IParameter ) {
|
||||||
addName(declarator.getName());
|
if ( declarator.getName() != null && declarator.getName().resolveBinding() == binding ) {
|
||||||
}
|
addName(declarator.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDeclSpecifier(org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier)
|
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDeclSpecifier(org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier)
|
||||||
*/
|
*/
|
||||||
public boolean processDeclSpecifier(IASTDeclSpecifier declSpec) {
|
public int processDeclSpecifier(IASTDeclSpecifier declSpec) {
|
||||||
if ( declSpec instanceof IASTSimpleDeclSpecifier ||
|
if ( declSpec instanceof IASTSimpleDeclSpecifier || declSpec instanceof ICASTTypedefNameSpecifier )
|
||||||
declSpec instanceof ICASTTypedefNameSpecifier ) return true;
|
return PROCESS_CONTINUE;
|
||||||
|
|
||||||
|
//if the binding isn't declared in a decl spec, skip it
|
||||||
|
if( !(binding instanceof ICompositeType) && !(binding instanceof IEnumeration) )
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
|
||||||
if ( !compositeTypeDeclared && declSpec != null && declSpec instanceof IASTCompositeTypeSpecifier ) {
|
if ( !compositeTypeDeclared && declSpec != null && declSpec instanceof IASTCompositeTypeSpecifier ) {
|
||||||
if (((IASTCompositeTypeSpecifier)declSpec).getName().resolveBinding() == binding) {
|
if (((IASTCompositeTypeSpecifier)declSpec).getName().resolveBinding() == binding) {
|
||||||
|
@ -343,38 +350,33 @@ public class CVisitor {
|
||||||
compositeTypeDeclared = true;
|
compositeTypeDeclared = true;
|
||||||
addName(((IASTEnumerationSpecifier)declSpec).getName());
|
addName(((IASTEnumerationSpecifier)declSpec).getName());
|
||||||
}
|
}
|
||||||
} else if ( declSpec instanceof IASTNamedTypeSpecifier ) {
|
|
||||||
if (((IASTNamedTypeSpecifier)declSpec).getName().resolveBinding() == binding)
|
|
||||||
addName(((IASTNamedTypeSpecifier)declSpec).getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processEnumerator(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
|
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processEnumerator(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
|
||||||
*/
|
*/
|
||||||
public boolean processEnumerator(IASTEnumerator enumerator) {
|
public int processEnumerator(IASTEnumerator enumerator) {
|
||||||
if (enumerator.getName().resolveBinding() == binding) {
|
if( binding instanceof IEnumerator && enumerator.getName().resolveBinding() == binding ){
|
||||||
IASTNode parent = enumerator.getParent();
|
addName( enumerator.getName() );
|
||||||
while (parent != null && !(parent instanceof IASTDeclaration))
|
|
||||||
parent = parent.getParent();
|
|
||||||
|
|
||||||
if (parent != null && parent instanceof IASTDeclaration) addName(enumerator.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processStatement(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processStatement(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
*/
|
*/
|
||||||
public boolean processStatement(IASTStatement statement) {
|
public int processStatement(IASTStatement statement) {
|
||||||
if ( statement instanceof IASTLabelStatement )
|
if ( statement instanceof IASTLabelStatement && binding instanceof ILabel ){
|
||||||
if ( ((IASTLabelStatement)statement).getName().resolveBinding() == binding )
|
if ( ((IASTLabelStatement)statement).getName().resolveBinding() == binding )
|
||||||
addName(((IASTLabelStatement)statement).getName());
|
addName(((IASTLabelStatement)statement).getName());
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,7 +1087,6 @@ public class CVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearBindings( IASTTranslationUnit tu ){
|
public static void clearBindings( IASTTranslationUnit tu ){
|
||||||
visitTranslationUnit( tu, new ClearBindingFromScopeAction() );
|
|
||||||
visitTranslationUnit( tu, new ClearBindingAction() );
|
visitTranslationUnit( tu, new ClearBindingAction() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1097,14 +1098,24 @@ public class CVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean visitName( IASTName name, CBaseVisitorAction action ){
|
public static boolean visitName( IASTName name, CBaseVisitorAction action ){
|
||||||
if( action.processNames )
|
if( action.processNames ) {
|
||||||
return action.processName( name );
|
switch( action.processName( name ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean visitDeclaration( IASTDeclaration declaration, CBaseVisitorAction action ){
|
public static boolean visitDeclaration( IASTDeclaration declaration, CBaseVisitorAction action ){
|
||||||
if( action.processDeclarations )
|
if( action.processDeclarations ) {
|
||||||
if( !action.processDeclaration( declaration ) ) return false;
|
switch( action.processDeclaration( declaration ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( declaration instanceof IASTSimpleDeclaration ){
|
if( declaration instanceof IASTSimpleDeclaration ){
|
||||||
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declaration;
|
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declaration;
|
||||||
|
@ -1122,10 +1133,17 @@ public class CVisitor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public static boolean visitDeclarator( IASTDeclarator declarator, CBaseVisitorAction action ){
|
public static boolean visitDeclarator( IASTDeclarator declarator, CBaseVisitorAction action ){
|
||||||
if( action.processDeclarators )
|
if( action.processDeclarators ){
|
||||||
if( !action.processDeclarator( declarator ) ) return false;
|
switch( action.processDeclarator( declarator ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !visitName( declarator.getName(), action ) ) return false;
|
if( declarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR ){
|
||||||
|
if( !visitName( declarator.getName(), action ) ) return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( declarator.getNestedDeclarator() != null )
|
if( declarator.getNestedDeclarator() != null )
|
||||||
if( !visitDeclarator( declarator.getNestedDeclarator(), action ) ) return false;
|
if( !visitDeclarator( declarator.getNestedDeclarator(), action ) ) return false;
|
||||||
|
@ -1136,21 +1154,18 @@ public class CVisitor {
|
||||||
if( declarator instanceof IASTStandardFunctionDeclarator ){
|
if( declarator instanceof IASTStandardFunctionDeclarator ){
|
||||||
IASTParameterDeclaration [] list = ((IASTStandardFunctionDeclarator)declarator).getParameters();
|
IASTParameterDeclaration [] list = ((IASTStandardFunctionDeclarator)declarator).getParameters();
|
||||||
for( int i = 0; i < list.length; i++ ){
|
for( int i = 0; i < list.length; i++ ){
|
||||||
IASTParameterDeclaration param = list[i];
|
if( !visitParameterDeclaration( list[i], action ) ) return false;
|
||||||
if( !visitDeclSpecifier( param.getDeclSpecifier(), action ) ) return false;
|
|
||||||
if( !visitDeclarator( param.getDeclarator(), action ) ) return false;
|
|
||||||
}
|
}
|
||||||
} else if ( declarator instanceof ICASTKnRFunctionDeclarator ) {
|
} else if ( declarator instanceof ICASTKnRFunctionDeclarator ) {
|
||||||
IASTDeclaration[] parmDeclarations = ((ICASTKnRFunctionDeclarator)declarator).getParameterDeclarations();
|
ICASTKnRFunctionDeclarator knr = (ICASTKnRFunctionDeclarator) declarator;
|
||||||
|
IASTName [] names = knr.getParameterNames();
|
||||||
|
for( int i = 0; i < names.length; i++ ){
|
||||||
|
if( !visitName( names[i], action ) ) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTDeclaration[] parmDeclarations = knr.getParameterDeclarations();
|
||||||
for( int i = 0; i < parmDeclarations.length; i++ ){
|
for( int i = 0; i < parmDeclarations.length; i++ ){
|
||||||
if ( parmDeclarations[i] instanceof IASTSimpleDeclaration ) {
|
if( !visitDeclaration( parmDeclarations[i], action ) ) return false;
|
||||||
IASTSimpleDeclaration parmDeclaration = (IASTSimpleDeclaration)parmDeclarations[i];
|
|
||||||
if( !visitDeclSpecifier( parmDeclaration.getDeclSpecifier(), action ) ) return false;
|
|
||||||
IASTDeclarator[] decltors = parmDeclaration.getDeclarators();
|
|
||||||
for ( int j = 0; j < decltors.length; j++ ) {
|
|
||||||
if( !visitDeclarator( decltors[j], action ) ) return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1159,8 +1174,15 @@ public class CVisitor {
|
||||||
public static boolean visitInitializer( IASTInitializer initializer, CBaseVisitorAction action ){
|
public static boolean visitInitializer( IASTInitializer initializer, CBaseVisitorAction action ){
|
||||||
if( initializer == null )
|
if( initializer == null )
|
||||||
return true;
|
return true;
|
||||||
if( action.processInitializers )
|
|
||||||
if( !action.processInitializer( initializer ) ) return false;
|
if( action.processInitializers ){
|
||||||
|
switch( action.processInitializer( initializer ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( initializer instanceof IASTInitializerExpression ){
|
if( initializer instanceof IASTInitializerExpression ){
|
||||||
if( !visitExpression( ((IASTInitializerExpression) initializer).getExpression(), action ) ) return false;
|
if( !visitExpression( ((IASTInitializerExpression) initializer).getExpression(), action ) ) return false;
|
||||||
} else if( initializer instanceof IASTInitializerList ){
|
} else if( initializer instanceof IASTInitializerList ){
|
||||||
|
@ -1172,8 +1194,13 @@ public class CVisitor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public static boolean visitParameterDeclaration( IASTParameterDeclaration parameterDeclaration, CBaseVisitorAction action ){
|
public static boolean visitParameterDeclaration( IASTParameterDeclaration parameterDeclaration, CBaseVisitorAction action ){
|
||||||
if( action.processParameterDeclarations )
|
if( action.processParameterDeclarations ){
|
||||||
if( !action.processParameterDeclaration( parameterDeclaration ) ) return false;
|
switch( action.processParameterDeclaration( parameterDeclaration ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !visitDeclSpecifier( parameterDeclaration.getDeclSpecifier(), action ) ) return false;
|
if( !visitDeclSpecifier( parameterDeclaration.getDeclSpecifier(), action ) ) return false;
|
||||||
if( !visitDeclarator( parameterDeclaration.getDeclarator(), action ) ) return false;
|
if( !visitDeclarator( parameterDeclaration.getDeclarator(), action ) ) return false;
|
||||||
|
@ -1181,8 +1208,13 @@ public class CVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean visitDeclSpecifier( IASTDeclSpecifier declSpec, CBaseVisitorAction action ){
|
public static boolean visitDeclSpecifier( IASTDeclSpecifier declSpec, CBaseVisitorAction action ){
|
||||||
if( action.processDeclSpecifiers )
|
if( action.processDeclSpecifiers ){
|
||||||
if( !action.processDeclSpecifier( declSpec ) ) return false;
|
switch( action.processDeclSpecifier( declSpec ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( declSpec instanceof ICASTCompositeTypeSpecifier ){
|
if( declSpec instanceof ICASTCompositeTypeSpecifier ){
|
||||||
ICASTCompositeTypeSpecifier compTypeSpec = (ICASTCompositeTypeSpecifier) declSpec;
|
ICASTCompositeTypeSpecifier compTypeSpec = (ICASTCompositeTypeSpecifier) declSpec;
|
||||||
|
@ -1207,17 +1239,28 @@ public class CVisitor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public static boolean visitEnumerator( IASTEnumerator enumerator, CBaseVisitorAction action ){
|
public static boolean visitEnumerator( IASTEnumerator enumerator, CBaseVisitorAction action ){
|
||||||
if( action.processEnumerators )
|
if( action.processEnumerators ){
|
||||||
if( !action.processEnumerator( enumerator ) ) return false;
|
switch( action.processEnumerator( enumerator ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !visitName( enumerator.getName(), action ) ) return false;
|
if( !visitName( enumerator.getName(), action ) ) return false;
|
||||||
if( enumerator.getValue() != null )
|
if( enumerator.getValue() != null )
|
||||||
if( !visitExpression( enumerator.getValue(), action ) ) return false;
|
if( !visitExpression( enumerator.getValue(), action ) ) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean visitStatement( IASTStatement statement, CBaseVisitorAction action ){
|
public static boolean visitStatement( IASTStatement statement, CBaseVisitorAction action ){
|
||||||
if( action.processStatements )
|
if( action.processStatements ){
|
||||||
if( !action.processStatement( statement ) ) return false;
|
switch( action.processStatement( statement ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( statement instanceof IASTCompoundStatement ){
|
if( statement instanceof IASTCompoundStatement ){
|
||||||
IASTStatement [] list = ((IASTCompoundStatement) statement).getStatements();
|
IASTStatement [] list = ((IASTCompoundStatement) statement).getStatements();
|
||||||
|
@ -1263,16 +1306,26 @@ public class CVisitor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public static boolean visitTypeId( IASTTypeId typeId, CBaseVisitorAction action ){
|
public static boolean visitTypeId( IASTTypeId typeId, CBaseVisitorAction action ){
|
||||||
if( action.processTypeIds )
|
if( action.processTypeIds ){
|
||||||
if( !action.processTypeId( typeId ) ) return false;
|
switch( action.processTypeId( typeId ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !visitDeclarator( typeId.getAbstractDeclarator(), action ) ) return false;
|
if( !visitDeclarator( typeId.getAbstractDeclarator(), action ) ) return false;
|
||||||
if( !visitDeclSpecifier( typeId.getDeclSpecifier(), action ) ) return false;
|
if( !visitDeclSpecifier( typeId.getDeclSpecifier(), action ) ) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public static boolean visitExpression( IASTExpression expression, CBaseVisitorAction action ){
|
public static boolean visitExpression( IASTExpression expression, CBaseVisitorAction action ){
|
||||||
if( action.processExpressions )
|
if( action.processExpressions ){
|
||||||
if( !action.processExpression( expression ) ) return false;
|
switch( action.processExpression( expression ) ){
|
||||||
|
case CPPBaseVisitorAction.PROCESS_ABORT : return false;
|
||||||
|
case CPPBaseVisitorAction.PROCESS_SKIP : return true;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( expression instanceof IASTArraySubscriptExpression ){
|
if( expression instanceof IASTArraySubscriptExpression ){
|
||||||
if( !visitExpression( ((IASTArraySubscriptExpression)expression).getArrayExpression(), action ) ) return false;
|
if( !visitExpression( ((IASTArraySubscriptExpression)expression).getArrayExpression(), action ) ) return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue