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

Patch for John Camelon:

CORE
	Added timing printout for CModelTests.
	Provided partial fix for bug36255 to get past infinite loop, will leave defect open.
	Fixed bug36045 (Again).  
	Fixed bug36287.

TESTS
	Updated ScannerTest::testBug36045().
	Added ScannerTest::testBug36287().
	Added DOMTests::testBug36288().
This commit is contained in:
Doug Schaefer 2003-04-09 14:52:28 +00:00
parent 22663266da
commit 3268c4fc9f
6 changed files with 92 additions and 8 deletions

View file

@ -1,7 +1,13 @@
2003-04-09 John Camelon
Added timing printout for CModelTests.
Provided partial fix for bug36255 to get past infinite loop, will leave defect open.
Fixed bug36045 (Again).
Fixed bug36287.
2003-04-06 Andrew Niefer
Added ParserSymbolTable::Cost and used it to fix up the conversion sequence ranking
2003-04-04 John Camelon
2003-04-06 John Camelon
Fixed defect 36073.
Fixed error handling for unterminated strings in Scanner.
Significantly updated callback structure to better suite the nature of the Code Model.

View file

@ -54,7 +54,9 @@ public class CModelBuilder {
String code = translationUnit.getBuffer().getContents();
Parser parser = new Parser(code, domBuilder, true);
if( ! parser.parse() ) throw new ParserException( "Parse failure" );
long startTime = System.currentTimeMillis();
generateModelElements(domBuilder.getTranslationUnit());
System.out.println("CModel build: "+ ( System.currentTimeMillis() - startTime ) + "ms" );
return domBuilder.getTranslationUnit();
}

View file

@ -348,6 +348,7 @@ public class Scanner implements IScanner {
private boolean throwExceptionOnEOFWithinMultilineComment = true;
private boolean throwExceptionOnEOFWithoutBalancedEndifs = true;
private boolean throwExceptionOnBadCharacterRead = false;
private boolean atEOF = false;
private boolean quickScan = false;
public void setQuickScan(boolean qs) {
@ -505,13 +506,16 @@ public class Scanner implements IScanner {
// string
StringBuffer buff = new StringBuffer();
int beforePrevious = NOCHAR;
int previous = c;
c = getChar(true);
for( ; ; )
{
if( ( c == '"' && previous != '\\' )|| ( c == NOCHAR) )break;
if ( ( c =='"' ) && ( previous != '\\' || beforePrevious == '\\') ) break;
if( c == NOCHAR) break;
buff.append((char) c);
beforePrevious = previous;
previous = c;
c = getChar(true);
}
@ -527,8 +531,7 @@ public class Scanner implements IScanner {
} else {
if (throwExceptionOnUnboundedString)
throw new ScannerException(
"Unbounded string found at offset "
+ currentContext.getOffset());
"Unbounded string" );
}
} else if (
@ -710,11 +713,17 @@ public class Scanner implements IScanner {
}
}
int tokenType = floatingPoint ? Token.tFLOATINGPT : Token.tINTEGER;
int tokenType;
String result = buff.toString();
if( floatingPoint && result.equals(".") )
tokenType = Token.tDOT;
else
tokenType = floatingPoint ? Token.tFLOATINGPT : Token.tINTEGER;
return newToken(
tokenType,
buff.toString(),
result,
currentContext);
} else if (c == '#') {
@ -1244,8 +1253,11 @@ public class Scanner implements IScanner {
}
}
if (throwExceptionOnEOFWithoutBalancedEndifs && ( getDepth() != 0))
if (throwExceptionOnEOFWithoutBalancedEndifs && ( getDepth() != 0) && !atEOF )
{
atEOF = true;
throw new ScannerException("End of file encountered without terminating #endif");
}
// we're done
throw Parser.endOfFile;

View file

@ -1,3 +1,8 @@
2003-04-09 John Camelon
Updated ScannerTest::testBug36045().
Added ScannerTest::testBug36287().
Added DOMTests::testBug36288().
2003-04-06 Andrew Niefer
Added ParserSymbolTableTest::testOverloadRanking()

View file

@ -1122,5 +1122,21 @@ public class DOMTests extends TestCase {
TranslationUnit tu = parse( writer.toString() );
}
public void testBug36288() throws Exception
{
TranslationUnit tu = parse( "int foo() {}\nlong foo2(){}", true);
assertEquals( tu.getDeclarations().size(), 2 );
for( int i = 0; i < 2; ++i )
{
SimpleDeclaration declaration = (SimpleDeclaration)tu.getDeclarations().get(i);
assertEquals( declaration.getDeclarators().size(), 1 );
Declarator d = (Declarator)declaration.getDeclarators().get(0);
assertEquals( d.getName().toString(), ( i == 0 ) ? "foo" : "foo2");
assertEquals( declaration.getDeclSpecifier().getType(), (i == 0 ) ? DeclSpecifier.t_int : DeclSpecifier.t_type );
assertEquals( declaration.getDeclSpecifier().isLong(), ( i == 0 ) ? false : true );
}
}
}

View file

@ -1142,6 +1142,42 @@ public class ScannerTestCase extends TestCase
}
}
public void testBug36287() throws Exception
{
initializeScanner( "X::X( const X & rtg_arg ) : U( rtg_arg ) , Z( rtg_arg.Z ) , br( rtg_arg.br ){}" );
validateIdentifier("X");
validateToken( Token.tCOLONCOLON);
validateIdentifier("X");
validateToken( Token.tLPAREN );
validateToken( Token.t_const );
validateIdentifier("X");
validateToken( Token.tAMPER );
validateIdentifier( "rtg_arg");
validateToken( Token.tRPAREN );
validateToken( Token.tCOLON );
validateIdentifier( "U");
validateToken( Token.tLPAREN );
validateIdentifier( "rtg_arg");
validateToken( Token.tRPAREN );
validateToken( Token.tCOMMA );
validateIdentifier( "Z");
validateToken( Token.tLPAREN );
validateIdentifier( "rtg_arg");
validateToken( Token.tDOT );
validateIdentifier( "Z");
validateToken( Token.tRPAREN );
validateToken( Token.tCOMMA );
validateIdentifier( "br");
validateToken( Token.tLPAREN );
validateIdentifier( "rtg_arg");
validateToken( Token.tDOT );
validateIdentifier( "br");
validateToken( Token.tRPAREN );
validateToken( Token.tLBRACE);
validateToken( Token.tRBRACE);
validateEOF();
}
public void testBug35892()
{
try
@ -1180,8 +1216,15 @@ public class ScannerTestCase extends TestCase
buffer.append( '\\');
buffer.append( '"');
buffer.append( '"');
buffer.append( '"');
buffer.append( '\\');
buffer.append( '\\');
buffer.append( '"');
buffer.append( "\n\n");
initializeScanner( buffer.toString());
validateString( "\\\"");
validateString( "\\\\");
}
public void testConditionalWithBraces()