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:
parent
da9f840d2e
commit
b7969ba527
2 changed files with 7 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue