1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 164470, using index for ambiguity resolution as part of parsing

This commit is contained in:
Markus Schorn 2006-12-06 15:09:46 +00:00
parent 2e2a574918
commit 3c449d0ac8
6 changed files with 27 additions and 9 deletions

View file

@ -45,7 +45,7 @@ public class IndexBindingResolutionBugs extends IndexBindingResolutionTestBase {
// cl* a; // cl* a;
// func(a); // func(a);
// } // }
public void _testBug166954() { public void testBug166954() {
IBinding b0 = getBindingFromASTName("func(a)", 4); IBinding b0 = getBindingFromASTName("func(a)", 4);
} }
} }

View file

@ -98,7 +98,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// cp->cs.*method(cp->cspp);/*1*/ &(cp->cs)->*method(cp->cspp);/*2*/ // cp->cs.*method(cp->cspp);/*1*/ &(cp->cs)->*method(cp->cspp);/*2*/
// } // }
public void _testPointerToMemberFields_2() throws IOException { public void _testPointerToMemberFields_2() throws IOException {
// fails with AST parser, only (the header is empty) // also fails without using the index (the header is empty)
IBinding b6 = getBindingFromASTName("method(cp->cspp);/*1*/", 6); IBinding b6 = getBindingFromASTName("method(cp->cspp);/*1*/", 6);
IBinding b7 = getBindingFromASTName("method(cp->cspp);/*2*/", 6); IBinding b7 = getBindingFromASTName("method(cp->cspp);/*2*/", 6);
} }
@ -584,7 +584,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
// // ?? foo/*o*/(); // ICPPASTTypenameExprssion // // ?? foo/*o*/(); // ICPPASTTypenameExprssion
// // foo/*p*/(MADE_UP_SYMBOL); // ICPPASTTypenameExprssion // // foo/*p*/(MADE_UP_SYMBOL); // ICPPASTTypenameExprssion
// } // }
public void _testExpressionKindForFunctionCalls() { public void testExpressionKindForFunctionCalls() {
// depends on bug 164470 because resolution takes place during parse. // depends on bug 164470 because resolution takes place during parse.
IBinding b0 = getBindingFromASTName("foo/*a*/", 3); IBinding b0 = getBindingFromASTName("foo/*a*/", 3);
IBinding b0a = getBindingFromASTName("cp[1]", 2); IBinding b0a = getBindingFromASTName("cp[1]", 2);

View file

@ -86,12 +86,10 @@ public class GCCLanguage extends AbstractLanguage {
ParserLanguage.C, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory); ParserLanguage.C, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
//assume GCC //assume GCC
ISourceCodeParser parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, log, ISourceCodeParser parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, log,
new GCCParserExtensionConfiguration() ); new GCCParserExtensionConfiguration(), index);
// Parse // Parse
IASTTranslationUnit ast = parser.parse(); IASTTranslationUnit ast = parser.parse();
// mstodo isn't that too late to set the index?
ast.setIndex(index);
return ast; return ast;
} }

View file

@ -86,12 +86,10 @@ public class GPPLanguage extends AbstractLanguage {
ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory); ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
//assume GCC //assume GCC
ISourceCodeParser parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, log, ISourceCodeParser parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, log,
new GPPParserExtensionConfiguration() ); new GPPParserExtensionConfiguration(), index );
// Parse // Parse
IASTTranslationUnit ast= parser.parse(); IASTTranslationUnit ast= parser.parse();
// mstodo isn't that too late to set the index?
ast.setIndex(index);
return ast; return ast;
} }

View file

@ -92,6 +92,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.dom.ast.gnu.c.IGCCASTArrayRangeDesignator; import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.EndOfFileException; import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IGCCToken; import org.eclipse.cdt.core.parser.IGCCToken;
import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IParserLogService;
@ -125,6 +126,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
private final boolean supportGCCStyleDesignators; private final boolean supportGCCStyleDesignators;
private IIndex index;
/** /**
* @param scanner * @param scanner
* @param parserMode * @param parserMode
@ -132,6 +135,12 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
*/ */
public GNUCSourceParser(IScanner scanner, ParserMode parserMode, public GNUCSourceParser(IScanner scanner, ParserMode parserMode,
IParserLogService logService, ICParserExtensionConfiguration config) { IParserLogService logService, ICParserExtensionConfiguration config) {
this(scanner, parserMode, logService, config, null);
}
public GNUCSourceParser(IScanner scanner, ParserMode parserMode,
IParserLogService logService, ICParserExtensionConfiguration config,
IIndex index) {
super(scanner, logService, parserMode, config super(scanner, logService, parserMode, config
.supportStatementsInExpressions(), config .supportStatementsInExpressions(), config
.supportTypeofUnaryExpressions(), config .supportTypeofUnaryExpressions(), config
@ -139,6 +148,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
.supportKnRC(), config.supportGCCOtherBuiltinSymbols(), .supportKnRC(), config.supportGCCOtherBuiltinSymbols(),
config.supportAttributeSpecifiers()); config.supportAttributeSpecifiers());
supportGCCStyleDesignators = config.supportGCCStyleDesignators(); supportGCCStyleDesignators = config.supportGCCStyleDesignators();
this.index= index;
} }
protected IASTInitializer optionalCInitializer() throws EndOfFileException, protected IASTInitializer optionalCInitializer() throws EndOfFileException,
@ -577,6 +587,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
protected void translationUnit() { protected void translationUnit() {
try { try {
translationUnit = createTranslationUnit(); translationUnit = createTranslationUnit();
translationUnit.setIndex(index);
// add built-in names to the scope // add built-in names to the scope
if (supportGCCOtherBuiltinSymbols) { if (supportGCCOtherBuiltinSymbols) {

View file

@ -131,6 +131,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.EndOfFileException; import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IGCCToken; import org.eclipse.cdt.core.parser.IGCCToken;
import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IParserLogService;
@ -1956,6 +1957,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private final boolean supportLongLong; private final boolean supportLongLong;
private final IIndex index;
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;
@ -1973,6 +1976,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
*/ */
public GNUCPPSourceParser(IScanner scanner, ParserMode mode, public GNUCPPSourceParser(IScanner scanner, ParserMode mode,
IParserLogService log, ICPPParserExtensionConfiguration config) { IParserLogService log, ICPPParserExtensionConfiguration config) {
this(scanner, mode, log, config, null);
}
public GNUCPPSourceParser(IScanner scanner, ParserMode mode,
IParserLogService log, ICPPParserExtensionConfiguration config,
IIndex index) {
super(scanner, log, mode, config.supportStatementsInExpressions(), super(scanner, log, mode, config.supportStatementsInExpressions(),
config.supportTypeofUnaryExpressions(), config config.supportTypeofUnaryExpressions(), config
.supportAlignOfUnaryExpression(), config.supportKnRC(), .supportAlignOfUnaryExpression(), config.supportKnRC(),
@ -1983,6 +1992,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
supportRestrict = config.supportRestrictKeyword(); supportRestrict = config.supportRestrictKeyword();
supportComplex = config.supportComplexNumbers(); supportComplex = config.supportComplexNumbers();
supportLongLong = config.supportLongLongs(); supportLongLong = config.supportLongLongs();
this.index= index;
} }
/** /**
@ -4634,6 +4644,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected void translationUnit() { protected void translationUnit() {
try { try {
translationUnit = createTranslationUnit(); translationUnit = createTranslationUnit();
translationUnit.setIndex(index);
// add built-in names to the scope // add built-in names to the scope
if (supportGCCOtherBuiltinSymbols) { if (supportGCCOtherBuiltinSymbols) {