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:
parent
2e2a574918
commit
3c449d0ac8
6 changed files with 27 additions and 9 deletions
|
@ -45,7 +45,7 @@ public class IndexBindingResolutionBugs extends IndexBindingResolutionTestBase {
|
|||
// cl* a;
|
||||
// func(a);
|
||||
// }
|
||||
public void _testBug166954() {
|
||||
public void testBug166954() {
|
||||
IBinding b0 = getBindingFromASTName("func(a)", 4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// cp->cs.*method(cp->cspp);/*1*/ &(cp->cs)->*method(cp->cspp);/*2*/
|
||||
// }
|
||||
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 b7 = getBindingFromASTName("method(cp->cspp);/*2*/", 6);
|
||||
}
|
||||
|
@ -584,7 +584,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// // ?? foo/*o*/(); // ICPPASTTypenameExprssion
|
||||
// // foo/*p*/(MADE_UP_SYMBOL); // ICPPASTTypenameExprssion
|
||||
// }
|
||||
public void _testExpressionKindForFunctionCalls() {
|
||||
public void testExpressionKindForFunctionCalls() {
|
||||
// depends on bug 164470 because resolution takes place during parse.
|
||||
IBinding b0 = getBindingFromASTName("foo/*a*/", 3);
|
||||
IBinding b0a = getBindingFromASTName("cp[1]", 2);
|
||||
|
|
|
@ -86,12 +86,10 @@ public class GCCLanguage extends AbstractLanguage {
|
|||
ParserLanguage.C, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
|
||||
//assume GCC
|
||||
ISourceCodeParser parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, log,
|
||||
new GCCParserExtensionConfiguration() );
|
||||
new GCCParserExtensionConfiguration(), index);
|
||||
|
||||
// Parse
|
||||
IASTTranslationUnit ast = parser.parse();
|
||||
// mstodo isn't that too late to set the index?
|
||||
ast.setIndex(index);
|
||||
return ast;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,12 +86,10 @@ public class GPPLanguage extends AbstractLanguage {
|
|||
ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
|
||||
//assume GCC
|
||||
ISourceCodeParser parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, log,
|
||||
new GPPParserExtensionConfiguration() );
|
||||
new GPPParserExtensionConfiguration(), index );
|
||||
|
||||
// Parse
|
||||
IASTTranslationUnit ast= parser.parse();
|
||||
// mstodo isn't that too late to set the index?
|
||||
ast.setIndex(index);
|
||||
return ast;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.IGCCASTArrayRangeDesignator;
|
||||
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.IGCCToken;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
|
@ -125,6 +126,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
private final boolean supportGCCStyleDesignators;
|
||||
|
||||
private IIndex index;
|
||||
|
||||
/**
|
||||
* @param scanner
|
||||
* @param parserMode
|
||||
|
@ -132,6 +135,12 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
*/
|
||||
public GNUCSourceParser(IScanner scanner, ParserMode parserMode,
|
||||
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
|
||||
.supportStatementsInExpressions(), config
|
||||
.supportTypeofUnaryExpressions(), config
|
||||
|
@ -139,6 +148,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
.supportKnRC(), config.supportGCCOtherBuiltinSymbols(),
|
||||
config.supportAttributeSpecifiers());
|
||||
supportGCCStyleDesignators = config.supportGCCStyleDesignators();
|
||||
this.index= index;
|
||||
}
|
||||
|
||||
protected IASTInitializer optionalCInitializer() throws EndOfFileException,
|
||||
|
@ -577,6 +587,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
protected void translationUnit() {
|
||||
try {
|
||||
translationUnit = createTranslationUnit();
|
||||
translationUnit.setIndex(index);
|
||||
|
||||
// add built-in names to the scope
|
||||
if (supportGCCOtherBuiltinSymbols) {
|
||||
|
|
|
@ -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.IGPPASTPointerToMember;
|
||||
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.IGCCToken;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
|
@ -1956,6 +1957,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
private final boolean supportLongLong;
|
||||
|
||||
private final IIndex index;
|
||||
|
||||
private static final int DEFAULT_PARM_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,
|
||||
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(),
|
||||
config.supportTypeofUnaryExpressions(), config
|
||||
.supportAlignOfUnaryExpression(), config.supportKnRC(),
|
||||
|
@ -1983,6 +1992,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
supportRestrict = config.supportRestrictKeyword();
|
||||
supportComplex = config.supportComplexNumbers();
|
||||
supportLongLong = config.supportLongLongs();
|
||||
this.index= index;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4634,6 +4644,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
protected void translationUnit() {
|
||||
try {
|
||||
translationUnit = createTranslationUnit();
|
||||
translationUnit.setIndex(index);
|
||||
|
||||
// add built-in names to the scope
|
||||
if (supportGCCOtherBuiltinSymbols) {
|
||||
|
|
Loading…
Add table
Reference in a new issue