1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Bug 401621 - CDT formatter hangs with 100% cpu load

This commit is contained in:
Sergey Prigogin 2013-05-30 21:44:37 -07:00
parent da9f840d2e
commit b7969ba527
2 changed files with 7 additions and 2 deletions

View file

@ -529,6 +529,9 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
// declarations, with a possible exception for the trailing semicolon
// of the last one. In both cases formatting is driven by the text of
// parameters of the macro, not by the expanded code.
scribe.setTailFormatter(
new TrailingTokenFormatter(Token.tSEMI, macroEndOffset,
preferences.insert_space_before_semicolon, false));
formatFunctionStyleMacroExpansion(macroExpansion);
}
}
@ -596,7 +599,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
localScanner.getNextToken(); // Skip the opening parenthesis.
int parenLevel = 0;
int token;
while ((token = localScanner.getNextToken()) != Token.tBADCHAR) {
while ((token = localScanner.getNextToken()) != -1) {
int tokenOffset = localScanner.getCurrentTokenStartPosition();
if (parenLevel == 0 && (token == Token.tCOMMA || token == Token.tRPAREN)) {
if (currentArgument != null) {

View file

@ -1289,6 +1289,7 @@ public class Scribe {
return hasWhitespace;
}
}
scanner.resetTo(currentTokenStartPosition, scannerEndPosition);
return hasWhitespace;
}
@ -2058,7 +2059,8 @@ public class Scribe {
}
final int currentPosition= scanner.getCurrentPosition();
if (offset > currentPosition) {
printRaw(currentPosition, currentPosition - offset);
fSkipStartOffset = Integer.MAX_VALUE;
printRaw(currentPosition, offset - currentPosition);
}
fSkipStartOffset= offset;
fSkipEndOffset= endOffset;