1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 134310 - Fix the GCC error parser which was really slow on long command lines. Now if the line is longer than a magic number (1000 for now), it is skipped since it's not likely to be an error message.

Bug 143952 - Skipping over "instantiated from here" so that it doesn't appear as an error.
This commit is contained in:
Doug Schaefer 2006-05-26 18:38:15 +00:00
parent 6c4db4a4b8
commit 316f28e9c0
5 changed files with 20 additions and 20 deletions

View file

@ -36,7 +36,8 @@ public class FileBasedErrorParserTests extends GenericErrorParserTests {
File dir = CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/")); File dir = CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/"));
File[] testsfiles = dir.listFiles(); File[] testsfiles = dir.listFiles();
for (int i = 0; i < testsfiles.length; i++) { for (int i = 0; i < testsfiles.length; i++) {
suite.addTest(new FileBasedErrorParserTests(testsfiles[i])); if (testsfiles[i].isFile())
suite.addTest(new FileBasedErrorParserTests(testsfiles[i]));
} }
return suite; return suite;
} }

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.core.internal.errorparsers.tests; package org.eclipse.cdt.core.internal.errorparsers.tests;
import java.io.IOException;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
@ -73,22 +75,22 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
return suite; return suite;
} }
public void testMultipleIncludesError() { public void testMultipleIncludesError() throws IOException {
runParserTest(GCC_ERROR_STREAM1, GCC_ERROR_STREAM1_ERRORS, GCC_ERROR_STREAM1_WARNINGS, GCC_ERROR_STREAM1_FILENAMES, null, runParserTest(GCC_ERROR_STREAM1, GCC_ERROR_STREAM1_ERRORS, GCC_ERROR_STREAM1_WARNINGS, GCC_ERROR_STREAM1_FILENAMES, null,
new String[]{GCC_ERROR_PARSER_ID}); new String[]{GCC_ERROR_PARSER_ID});
} }
public void testMultiLineDescriptionError() { public void testMultiLineDescriptionError() throws IOException {
runParserTest(GCC_ERROR_STREAM2, GCC_ERROR_STREAM2_ERRORS, GCC_ERROR_STREAM2_WARNINGS, GCC_ERROR_STREAM2_FILENAMES, runParserTest(GCC_ERROR_STREAM2, GCC_ERROR_STREAM2_ERRORS, GCC_ERROR_STREAM2_WARNINGS, GCC_ERROR_STREAM2_FILENAMES,
GCC_ERROR_STREAM2_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID}); GCC_ERROR_STREAM2_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
} }
public void testLongMultiLineDescriptionError() { public void testLongMultiLineDescriptionError() throws IOException {
runParserTest(GCC_ERROR_STREAM3, GCC_ERROR_STREAM3_ERRORS, GCC_ERROR_STREAM3_WARNINGS, GCC_ERROR_STREAM3_FILENAMES, runParserTest(GCC_ERROR_STREAM3, GCC_ERROR_STREAM3_ERRORS, GCC_ERROR_STREAM3_WARNINGS, GCC_ERROR_STREAM3_FILENAMES,
GCC_ERROR_STREAM3_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID}); GCC_ERROR_STREAM3_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
} }
public void testMultiFileMultiLineSingleError() { public void testMultiFileMultiLineSingleError() throws IOException {
runParserTest(GCC_ERROR_STREAM4, GCC_ERROR_STREAM4_ERRORS, GCC_ERROR_STREAM4_WARNINGS, GCC_ERROR_STREAM4_FILENAMES, runParserTest(GCC_ERROR_STREAM4, GCC_ERROR_STREAM4_ERRORS, GCC_ERROR_STREAM4_WARNINGS, GCC_ERROR_STREAM4_FILENAMES,
GCC_ERROR_STREAM4_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID}); GCC_ERROR_STREAM4_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
} }

View file

@ -102,7 +102,7 @@ public class GenericErrorParserTests extends TestCase {
} }
protected void runParserTest(InputStream inputStream, int expectedErrorCount, int expectedWarningCount, protected void runParserTest(InputStream inputStream, int expectedErrorCount, int expectedWarningCount,
String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) { String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) throws IOException {
assertNotNull(inputStream); assertNotNull(inputStream);
@ -114,17 +114,8 @@ public class GenericErrorParserTests extends TestCase {
ErrorParserManager manager; ErrorParserManager manager;
manager = new ImaginaryFilesErrorParserManager(project, markerGenerator, parserID); manager = new ImaginaryFilesErrorParserManager(project, markerGenerator, parserID);
try { transferInputStreamToOutputStream(inputStream, manager.getOutputStream(), 1024);
transferInputStreamToOutputStream(inputStream, manager.getOutputStream(), 1024); manager.close();
} catch (Exception ex) {
assertTrue(false);
} finally {
try {
manager.close();
} catch (Exception ex) {
/* Ignore */
}
}
manager.reportProblems(); manager.reportProblems();
if (expectedErrorCount >= 0) { if (expectedErrorCount >= 0) {
@ -150,7 +141,7 @@ public class GenericErrorParserTests extends TestCase {
} }
protected void runParserTest(String[] dataStream, int expectedErrorCount, int expectedWarningCount, String[] expectedFileNames, protected void runParserTest(String[] dataStream, int expectedErrorCount, int expectedWarningCount, String[] expectedFileNames,
String[] expectedDescriptions, String[] parserID) { String[] expectedDescriptions, String[] parserID) throws IOException {
String errorStream = makeStringFromArray(dataStream, "\n"); String errorStream = makeStringFromArray(dataStream, "\n");
ByteArrayInputStream inputStream = new ByteArrayInputStream(errorStream.getBytes()); ByteArrayInputStream inputStream = new ByteArrayInputStream(errorStream.getBytes());

View file

@ -187,6 +187,11 @@ public class ErrorParserManager extends OutputStream {
if (fErrorParsers.size() == 0) if (fErrorParsers.size() == 0)
return; return;
// If the line is too long, it is most likely a command line and not an error message
// Don't process it since it'll probably be really slow and won't find an error anyway
if (line.length() > 1000)
return;
String[] parserIDs = new String[fErrorParsers.size()]; String[] parserIDs = new String[fErrorParsers.size()];
Iterator items = fErrorParsers.keySet().iterator(); Iterator items = fErrorParsers.keySet().iterator();
for (int i = 0; items.hasNext(); i++) { for (int i = 0; items.hasNext(); i++) {

View file

@ -30,8 +30,9 @@ public class GCCErrorParser extends AbstractErrorParser {
new ErrorPattern("\\(Each undeclared identifier is reported only once"), new ErrorPattern("\\(Each undeclared identifier is reported only once"),
new ErrorPattern("for each function it appears in.\\)"), new ErrorPattern("for each function it appears in.\\)"),
new ErrorPattern(": note:"), new ErrorPattern(": note:"),
new ErrorPattern("instantiated from here"),
// The following are not... // The following are not...
new ErrorPattern("((.:)?[^:]*):([0-9]*):([0-9]*:)? ((warning: )?.*)", 1, 3, 5, 0, 0) { new ErrorPattern("(.*?):([0-9]+):([0-9]+:)? ((warning: )?.*)", 1, 2, 4, 0, 0) {
public String getVarName(Matcher matcher) { public String getVarName(Matcher matcher) {
String desc = getDesc(matcher); String desc = getDesc(matcher);
Matcher varMatcher = null; Matcher varMatcher = null;
@ -46,7 +47,7 @@ public class GCCErrorParser extends AbstractErrorParser {
return varMatcher != null ? varMatcher.group(1) : null; return varMatcher != null ? varMatcher.group(1) : null;
} }
public int getSeverity(Matcher matcher) { public int getSeverity(Matcher matcher) {
String warningGroup = matcher.group(6); String warningGroup = matcher.group(5);
if (warningGroup != null) if (warningGroup != null)
return IMarkerGenerator.SEVERITY_WARNING; return IMarkerGenerator.SEVERITY_WARNING;
else else