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:
parent
22663266da
commit
3268c4fc9f
6 changed files with 92 additions and 8 deletions
|
@ -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
|
2003-04-06 Andrew Niefer
|
||||||
Added ParserSymbolTable::Cost and used it to fix up the conversion sequence ranking
|
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 defect 36073.
|
||||||
Fixed error handling for unterminated strings in Scanner.
|
Fixed error handling for unterminated strings in Scanner.
|
||||||
Significantly updated callback structure to better suite the nature of the Code Model.
|
Significantly updated callback structure to better suite the nature of the Code Model.
|
||||||
|
|
|
@ -53,8 +53,10 @@ public class CModelBuilder {
|
||||||
DOMBuilder domBuilder = new DOMBuilder();
|
DOMBuilder domBuilder = new DOMBuilder();
|
||||||
String code = translationUnit.getBuffer().getContents();
|
String code = translationUnit.getBuffer().getContents();
|
||||||
Parser parser = new Parser(code, domBuilder, true);
|
Parser parser = new Parser(code, domBuilder, true);
|
||||||
if( ! parser.parse() ) throw new ParserException( "Parse failure" );
|
if( ! parser.parse() ) throw new ParserException( "Parse failure" );
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
generateModelElements(domBuilder.getTranslationUnit());
|
generateModelElements(domBuilder.getTranslationUnit());
|
||||||
|
System.out.println("CModel build: "+ ( System.currentTimeMillis() - startTime ) + "ms" );
|
||||||
return domBuilder.getTranslationUnit();
|
return domBuilder.getTranslationUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,6 +348,7 @@ public class Scanner implements IScanner {
|
||||||
private boolean throwExceptionOnEOFWithinMultilineComment = true;
|
private boolean throwExceptionOnEOFWithinMultilineComment = true;
|
||||||
private boolean throwExceptionOnEOFWithoutBalancedEndifs = true;
|
private boolean throwExceptionOnEOFWithoutBalancedEndifs = true;
|
||||||
private boolean throwExceptionOnBadCharacterRead = false;
|
private boolean throwExceptionOnBadCharacterRead = false;
|
||||||
|
private boolean atEOF = false;
|
||||||
|
|
||||||
private boolean quickScan = false;
|
private boolean quickScan = false;
|
||||||
public void setQuickScan(boolean qs) {
|
public void setQuickScan(boolean qs) {
|
||||||
|
@ -505,13 +506,16 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
// string
|
// string
|
||||||
StringBuffer buff = new StringBuffer();
|
StringBuffer buff = new StringBuffer();
|
||||||
|
int beforePrevious = NOCHAR;
|
||||||
int previous = c;
|
int previous = c;
|
||||||
c = getChar(true);
|
c = getChar(true);
|
||||||
|
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{
|
{
|
||||||
if( ( c == '"' && previous != '\\' )|| ( c == NOCHAR) )break;
|
if ( ( c =='"' ) && ( previous != '\\' || beforePrevious == '\\') ) break;
|
||||||
|
if( c == NOCHAR) break;
|
||||||
buff.append((char) c);
|
buff.append((char) c);
|
||||||
|
beforePrevious = previous;
|
||||||
previous = c;
|
previous = c;
|
||||||
c = getChar(true);
|
c = getChar(true);
|
||||||
}
|
}
|
||||||
|
@ -527,8 +531,7 @@ public class Scanner implements IScanner {
|
||||||
} else {
|
} else {
|
||||||
if (throwExceptionOnUnboundedString)
|
if (throwExceptionOnUnboundedString)
|
||||||
throw new ScannerException(
|
throw new ScannerException(
|
||||||
"Unbounded string found at offset "
|
"Unbounded string" );
|
||||||
+ currentContext.getOffset());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (
|
} 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(
|
return newToken(
|
||||||
tokenType,
|
tokenType,
|
||||||
buff.toString(),
|
result,
|
||||||
currentContext);
|
currentContext);
|
||||||
|
|
||||||
} else if (c == '#') {
|
} 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");
|
throw new ScannerException("End of file encountered without terminating #endif");
|
||||||
|
}
|
||||||
|
|
||||||
// we're done
|
// we're done
|
||||||
throw Parser.endOfFile;
|
throw Parser.endOfFile;
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-04-09 John Camelon
|
||||||
|
Updated ScannerTest::testBug36045().
|
||||||
|
Added ScannerTest::testBug36287().
|
||||||
|
Added DOMTests::testBug36288().
|
||||||
|
|
||||||
2003-04-06 Andrew Niefer
|
2003-04-06 Andrew Niefer
|
||||||
Added ParserSymbolTableTest::testOverloadRanking()
|
Added ParserSymbolTableTest::testOverloadRanking()
|
||||||
|
|
||||||
|
|
|
@ -1121,6 +1121,22 @@ public class DOMTests extends TestCase {
|
||||||
writer.write( "A::A(const A&v) : x(v.x) { }\n" );
|
writer.write( "A::A(const A&v) : x(v.x) { }\n" );
|
||||||
TranslationUnit tu = parse( writer.toString() );
|
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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1141,6 +1141,42 @@ public class ScannerTestCase extends TestCase
|
||||||
validateAsUndefined(row.symbolName(i));
|
validateAsUndefined(row.symbolName(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
public void testBug35892()
|
||||||
{
|
{
|
||||||
|
@ -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( '\\');
|
||||||
|
buffer.append( '\\');
|
||||||
|
buffer.append( '"');
|
||||||
|
buffer.append( "\n\n");
|
||||||
initializeScanner( buffer.toString());
|
initializeScanner( buffer.toString());
|
||||||
validateString( "\\\"");
|
validateString( "\\\"");
|
||||||
|
validateString( "\\\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConditionalWithBraces()
|
public void testConditionalWithBraces()
|
||||||
|
|
Loading…
Add table
Reference in a new issue