[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied [HEAD] - Fixes from before the power blackout
|
CORE
Fixed Bug 39530 - More problems with initializers.
Fixed Bug 37424 - Crash when opening big files
Refactored pointerOperators & cvQualifiers to not throw backtracks
in optional case.
Added tracing support to cdt.core plugin via .options file.
TESTS
Added QuickParseASTTests::testBug39530().
JohnC
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.65
diff -u -r1.65 ChangeLog
--- ChangeLog 25 Aug 2003 04:20:47 -0000 1.65
+++ ChangeLog 25 Aug 2003 12:19:11 -0000
@@ -1,3 +1,6 @@
+2003-08-25 John Camelon
+ Added QuickParseASTTests::testBug39530().
+
2003-08-21 Hoda Amer
Enabled some tests in the IStructureTests, namely:
testGetFields(), testGetField(), testGetMethods(), testGetMethod(),
Index: parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java,v
retrieving revision 1.12
diff -u -r1.12 QuickParseASTTests.java
--- parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java 13 Aug 2003 21:51:53 -0000 1.12
+++ parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java 25 Aug 2003 12:19:12 -0000
@@ -1763,4 +1763,10 @@
parse("class {} const null;");
assertTrue( quickParseCallback.getCompilationUnit().getDeclarations().hasNext() );
}
+
+ public void testBug39530() throws Exception
+ {
+ parse( "X sPassed(-1)");
+ }
+
}
Index: .options
===================================================================
RCS file: .options
diff -N .options
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ .options 25 Aug 2003 12:18:51 -0000
@@ -0,0 +1 @@
+org.eclipse.cdt.core/debug=true
\ No newline at end of file
Index: model/org/eclipse/cdt/internal/core/model/Util.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java,v
retrieving revision 1.4
diff -u -r1.4 Util.java
--- model/org/eclipse/cdt/internal/core/model/Util.java 27 Apr 2003 20:56:07 -0000 1.4
+++ model/org/eclipse/cdt/internal/core/model/Util.java 25 Aug 2003 12:18:52 -0000
@@ -174,7 +174,8 @@
}
public static void debugLog(String message) {
- if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().isDebugging()) {
+ if( CCorePlugin.getDefault() == null ) return;
+ if ( CCorePlugin.getDefault().isDebugging()) {
// Time stamp
message = MessageFormat.format( "[{0}] {1}", new Object[] { new Long( System.currentTimeMillis() ), message } );
while (message.length() > 100) {
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.102
diff -u -r1.102 ChangeLog
--- parser/ChangeLog 14 Aug 2003 19:49:44 -0000 1.102
+++ parser/ChangeLog 25 Aug 2003 12:18:52 -0000
@@ -1,3 +1,9 @@
+2003-08-25 John Camelon
+ Fixed Bug 39530 - More problems with initializers.
+ Fixed Bug 37424 - Crash when opening big files
+ Refactored pointerOperators & cvQualifiers to not throw backtracks in optional case.
+ Added tracing support to cdt.core plugin via .options file.
+
2003-08-14 John Camelon
Removed warnings from SymbolTable & QuickParseCallback (removing implicit accessor generation).
Made IASTElaboratedTypeSpecifier derive from IASTOffsetableNamedElement (as it should).
Index: parser/org/eclipse/cdt/core/parser/IScanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java,v
retrieving revision 1.10
diff -u -r1.10 IScanner.java
--- parser/org/eclipse/cdt/core/parser/IScanner.java 18 Jul 2003 16:39:22 -0000 1.10
+++ parser/org/eclipse/cdt/core/parser/IScanner.java 25 Aug 2003 12:18:52 -0000
@@ -32,4 +32,9 @@
public void setTokenizingMacroReplacementList(boolean b);
public void onParseEnd();
+ /**
+ * @param i
+ * @return
+ */
+ public int getLineNumberForOffset(int i);
}
Index: parser/org/eclipse/cdt/internal/core/parser/ContextStack.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextStack.java,v
retrieving revision 1.11
diff -u -r1.11 ContextStack.java
--- parser/org/eclipse/cdt/internal/core/parser/ContextStack.java 21 Jul 2003 17:29:55 -0000 1.11
+++ parser/org/eclipse/cdt/internal/core/parser/ContextStack.java 25 Aug 2003 12:18:53 -0000
@@ -22,6 +22,7 @@
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ScannerException;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+import org.eclipse.cdt.internal.core.model.Util;
/**
* @author aniefer
@@ -85,7 +86,7 @@
try {
currentContext.getReader().close();
} catch (IOException ie) {
- System.out.println("Error closing reader");
+ Util.debugLog("ContextStack : Error closing reader ");
}
if( currentContext.getKind() == IScannerContext.INCLUSION )
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java,v
retrieving revision 1.93
diff -u -r1.93 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java 20 Aug 2003 18:05:30 -0000 1.93
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java 25 Aug 2003 12:18:54 -0000
@@ -793,7 +793,7 @@
DeclarationWrapper sdw =
new DeclarationWrapper(scope, LA(1).getOffset(), ownerTemplate);
- declSpecifierSeq(false, tryConstructor, sdw);
+ declSpecifierSeq(false, tryConstructor, sdw, forKR );
try
{
if (sdw.getTypeSpecifier() == null && sdw.getSimpleType() != IASTSimpleTypeSpecifier.Type.UNSPECIFIED )
@@ -816,14 +816,14 @@
if (LT(1) != IToken.tSEMI)
try
{
- declarator = initDeclarator(sdw);
+ declarator = initDeclarator(sdw, forKR);
while (LT(1) == IToken.tCOMMA)
{
consume();
try
{
- initDeclarator(sdw);
+ initDeclarator(sdw, forKR);
}
catch (Backtrack b)
{
@@ -1010,7 +1010,7 @@
DeclarationWrapper sdw =
new DeclarationWrapper(scope, current.getOffset(), null);
- declSpecifierSeq(true, false, sdw);
+ declSpecifierSeq(true, false, sdw, false);
try
{
if (sdw.getTypeSpecifier() == null
@@ -1034,7 +1034,7 @@
if (LT(1) != IToken.tSEMI)
try
{
- initDeclarator(sdw);
+ initDeclarator(sdw, false);
}
catch (Backtrack b)
{
@@ -1219,7 +1219,8 @@
protected void declSpecifierSeq(
boolean parm,
boolean tryConstructor,
- DeclarationWrapper sdw)
+ DeclarationWrapper sdw,
+ boolean forKR )
throws Backtrack
{
Flags flags = new Flags(parm, tryConstructor);
@@ -1418,7 +1419,7 @@
case IToken.t_class :
case IToken.t_struct :
case IToken.t_union :
- if (!parm)
+ if (!parm && !forKR )
{
try
{
@@ -1440,7 +1441,7 @@
break;
}
case IToken.t_enum :
- if (!parm)
+ if (!parm || !forKR )
{
try
{
@@ -1684,7 +1685,7 @@
* @return Returns the same object sent in.
* @throws Backtrack
*/
- protected void cvQualifier(
+ protected boolean cvQualifier(
Declarator declarator)
throws Backtrack
{
@@ -1693,13 +1694,13 @@
case IToken.t_const :
consume( IToken.t_const );
declarator.addPtrOp(ASTPointerOperator.CONST_POINTER);
- return;
+ return true;
case IToken.t_volatile :
consume( IToken.t_volatile );
declarator.addPtrOp(ASTPointerOperator.VOLATILE_POINTER);
- return;
+ return true;
default :
- throw backtrack;
+ return false;
}
}
/**
@@ -1712,10 +1713,10 @@
* @throws Backtrack request a backtrack
*/
protected Declarator initDeclarator(
- DeclarationWrapper sdw)
+ DeclarationWrapper sdw, boolean forKR )
throws Backtrack
{
- Declarator d = declarator(sdw, sdw.getScope());
+ Declarator d = declarator(sdw, sdw.getScope(), forKR );
// handle = initializerClause
if (LT(1) == IToken.tASSIGN)
{
@@ -1810,7 +1811,7 @@
* @throws Backtrack request a backtrack
*/
protected Declarator declarator(
- IDeclaratorOwner owner, IASTScope scope)
+ IDeclaratorOwner owner, IASTScope scope, boolean forKR )
throws Backtrack
{
Declarator d = null;
@@ -1819,21 +1820,12 @@
{
d = new Declarator(owner);
- for (;;)
- {
- try
- {
- ptrOperator(d);
- }
- catch (Backtrack b)
- {
- break;
- }
- }
+ consumePointerOperators(d, false);
+
if (LT(1) == IToken.tLPAREN)
{
consume();
- declarator(d, scope);
+ declarator(d, scope, forKR);
consume(IToken.tRPAREN);
}
else if (LT(1) == IToken.t_operator)
@@ -1879,8 +1871,11 @@
switch (LT(1))
{
case IToken.tLPAREN :
+ if( forKR )
+ throw backtrack;
+
// temporary fix for initializer/function declaration ambiguity
- if (!LA(2).looksLikeExpression())
+ if (!LA(2).looksLikeExpression() )
{
// parameterDeclarationClause
d.setIsFunction(true);
@@ -2030,7 +2025,7 @@
}
while (LT(1) != IToken.tLBRACE);
}
- catch (Exception e)
+ catch (Backtrack bt)
{
// Something is wrong,
// this is not a proper K&R declaration clause
@@ -2122,8 +2117,9 @@
{
// this ptrOp doesn't belong to the declarator,
// it's just a part of the name
- ptrOperator(d);
- toSend = lastToken;
+ consumePointerOperators(d, true);
+ if( lastToken != null )
+ toSend = lastToken;
}
catch (Backtrack b)
{
@@ -2149,50 +2145,59 @@
* @param owner Declarator that this pointer operator corresponds to.
* @throws Backtrack request a backtrack
*/
- protected void ptrOperator(Declarator d) throws Backtrack
+ protected void consumePointerOperators(Declarator d, boolean consumeOnlyOne) throws Backtrack
{
- int t = LT(1);
- if (t == IToken.tAMPER)
- {
- consume( IToken.tAMPER );
- d.addPtrOp(ASTPointerOperator.REFERENCE);
- return;
- }
- IToken mark = mark();
- IToken tokenType = LA(1);
- ITokenDuple nameDuple = null;
- if (t == IToken.tIDENTIFIER || t == IToken.tCOLONCOLON)
- {
- nameDuple = name();
- t = LT(1);
- }
- if (t == IToken.tSTAR)
- {
- tokenType = consume(Token.tSTAR); // tokenType = "*"
-
- d.setPointerOperatorName(nameDuple);
-
- boolean successful = false;
- for (;;)
- {
- try
- {
- cvQualifier(d);
- successful = true;
- }
- catch (Backtrack b)
- {
- // expected at some point
- break;
- }
- }
- if( !successful )
- d.addPtrOp( ASTPointerOperator.POINTER );
-
- return;
- }
- backup(mark);
- throw backtrack;
+ for( ; ; )
+ {
+ int t = LT(1);
+ if (t == IToken.tAMPER)
+ {
+ consume( IToken.tAMPER );
+ d.addPtrOp(ASTPointerOperator.REFERENCE);
+ if( consumeOnlyOne ) return;
+ continue;
+ }
+ IToken mark = mark();
+ IToken tokenType = LA(1);
+ ITokenDuple nameDuple = null;
+ if (t == IToken.tIDENTIFIER || t == IToken.tCOLONCOLON)
+ {
+ try
+ {
+ nameDuple = name();
+ }
+ catch( Backtrack bt )
+ {
+ backup( mark );
+ return;
+ }
+ t = LT(1);
+ }
+ if (t == IToken.tSTAR)
+ {
+ tokenType = consume(Token.tSTAR); // tokenType = "*"
+
+ d.setPointerOperatorName(nameDuple);
+
+ boolean successful = false;
+ for (;;)
+ {
+ boolean newSuccess = cvQualifier(d);
+ if( newSuccess ) successful = true;
+ else break;
+
+ }
+
+ if( !successful )
+ {
+ d.addPtrOp( ASTPointerOperator.POINTER );
+ }
+ if( consumeOnlyOne ) return;
+ continue;
+ }
+ backup(mark);
+ return;
+ }
}
/**
* Parse an enumeration specifier, as according to the ANSI specs in C & C++.
@@ -4401,6 +4406,9 @@
private IScanner scanner;
private IToken currToken, // current token we plan to consume next
lastToken; // last token we consumed
+
+ private int highWaterOffset = 0;
+
/**
* Fetches a token from the scanner.
*
@@ -4411,7 +4419,17 @@
{
try
{
- return scanner.nextToken();
+ IToken t = scanner.nextToken();
+ if( t.getEndOffset() > highWaterOffset )
+ highWaterOffset = t.getEndOffset();
+ if( t.getOffset() == 872556 )
+ {
+ Util.debugLog( "This is the point of failure.");
+ Util.debugLog( "Token is of image =" + t.getImage() );
+ Util.debugLog( "Token is on line " + scanner.getLineNumberForOffset( t.getOffset() ) );
+ }
+ Util.debugLog( "FetchToken retrieved token w/offset=" + t.getOffset() );
+ return t;
}
catch (EndOfFile e)
{
@@ -4419,7 +4437,7 @@
}
catch (ScannerException e)
{
- // e.printStackTrace();
+ Util.debugLog( "ScannerException thrown : " + e.getMessage() );
return fetchToken();
}
}
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.47
diff -u -r1.47 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 14 Aug 2003 15:33:27 -0000 1.47
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 25 Aug 2003 12:18:55 -0000
@@ -26,6 +26,7 @@
import org.eclipse.cdt.core.parser.Backtrack;
import org.eclipse.cdt.core.parser.EndOfFile;
+import org.eclipse.cdt.core.parser.ILineOffsetReconciler;
import org.eclipse.cdt.core.parser.IMacroDescriptor;
import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.IProblemReporter;
@@ -42,6 +43,7 @@
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+import org.eclipse.cdt.internal.core.model.Util;
/**
@@ -51,10 +53,13 @@
public class Scanner implements IScanner {
- public Scanner(Reader reader, String filename, IScannerInfo info, IProblemReporter problemReporter, ITranslationResult unitResult, ISourceElementRequestor requestor, ParserMode parserMode ) {
+ private Reader backupReader;
+
+ public Scanner(Reader reader, String filename, IScannerInfo info, IProblemReporter problemReporter, ITranslationResult unitResult, ISourceElementRequestor requestor, ParserMode parserMode ) {
this.requestor = requestor;
this.mode = parserMode;
astFactory = ParserFactory.createASTFactory( mode );
+ this.backupReader = reader;
try {
//this is a hack to get around a sudden EOF experience
@@ -2133,7 +2138,7 @@
BAD_PP + contextStack.getCurrentContext().getOffset());
}
} else {
- System.out.println("Unexpected character " + ((char) c));
+ Util.debugLog("Scanner : Encountered unexpected character " + ((char) c));
if (throwExceptionOnBadPreprocessorSyntax)
throw new ScannerException(BAD_PP + contextStack.getCurrentContext().getOffset());
}
@@ -2325,7 +2330,7 @@
"Improper use of macro " + symbol);
} else {
- System.out.println(
+ Util.debugLog(
"Unexpected class stored in definitions table. "
+ expansion.getClass().getName());
}
@@ -2546,4 +2551,15 @@
}
}
}
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.IScanner#getLineNumberForOffset(int)
+ */
+ public int getLineNumberForOffset(int i)
+ {
+ ILineOffsetReconciler reconciler = ParserFactory.createLineOffsetReconciler( backupReader );
+ return reconciler.getLineNumberForOffset(i);
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/Token.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java,v
retrieving revision 1.17
diff -u -r1.17 Token.java
--- parser/org/eclipse/cdt/internal/core/parser/Token.java 28 Jun 2003 22:39:33 -0000 1.17
+++ parser/org/eclipse/cdt/internal/core/parser/Token.java 25 Aug 2003 12:18:55 -0000
@@ -78,6 +78,11 @@
case tAMPER:
case tDOT:
case tLPAREN:
+ case tMINUS:
+ case tSTAR:
+ case tPLUS:
+ case tNOT:
+ case tCOMPL:
return true;
default:
break;