summaryrefslogtreecommitdiff
path: root/src/libs/3rdparty/cplusplus/Parser.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2013-01-08 03:32:53 +0200
committerhjk <qthjk@ovi.com>2013-01-08 10:48:18 +0100
commit29a93998df8405e8799ad23934a56cd99fb36403 (patch)
treec0e4a341efeef78fbe530a618caaa50254daad59 /src/libs/3rdparty/cplusplus/Parser.cpp
parent73a2717bed511cffd0163195c314f7d919e5128b (diff)
downloadqt-creator-29a93998df8405e8799ad23934a56cd99fb36403.tar.gz
Remove braces for single lines of conditions
#!/usr/bin/env ruby Dir.glob('**/*.cpp') { |file| # skip ast (excluding paste, astpath, and canv'ast'imer) next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i s = File.read(file) next if s.include?('qlalr') orig = s.dup s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m| res = $& if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces res else res.gsub!('} else', 'else') res.gsub!(/\n +} *\n/m, "\n") res.gsub(/ *{$/, '') end } s.gsub!(/ *$/, '') File.open(file, 'wb').write(s) if s != orig } Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Parser.cpp')
-rw-r--r--src/libs/3rdparty/cplusplus/Parser.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp
index be92fcf673..dc9448cd72 100644
--- a/src/libs/3rdparty/cplusplus/Parser.cpp
+++ b/src/libs/3rdparty/cplusplus/Parser.cpp
@@ -898,9 +898,8 @@ bool Parser::parseConversionFunctionId(NameAST *&node)
return false;
unsigned operator_token = consumeToken();
SpecifierListAST *type_specifier = 0;
- if (! parseTypeSpecifier(type_specifier)) {
+ if (! parseTypeSpecifier(type_specifier))
return false;
- }
PtrOperatorListAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators;
while (parsePtrOperator(*ptr_operators_tail))
ptr_operators_tail = &(*ptr_operators_tail)->next;
@@ -1550,9 +1549,8 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specif
for (SpecifierListAST *iter = decl_specifier_list; !hasAuto && iter; iter = iter->next) {
SpecifierAST *spec = iter->value;
if (SimpleSpecifierAST *simpleSpec = spec->asSimpleSpecifier()) {
- if (_translationUnit->tokenKind(simpleSpec->specifier_token) == T_AUTO) {
+ if (_translationUnit->tokenKind(simpleSpec->specifier_token) == T_AUTO)
hasAuto = true;
- }
}
}
@@ -1567,9 +1565,8 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specif
} else if (LA() == T_LBRACKET) {
ArrayDeclaratorAST *ast = new (_pool) ArrayDeclaratorAST;
ast->lbracket_token = consumeToken();
- if (LA() == T_RBRACKET || parseConstantExpression(ast->expression)) {
+ if (LA() == T_RBRACKET || parseConstantExpression(ast->expression))
match(T_RBRACKET, &ast->rbracket_token);
- }
*postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else
@@ -1715,9 +1712,8 @@ bool Parser::parseEnumSpecifier(SpecifierListAST *&node)
skipUntil(T_IDENTIFIER);
}
- if (parseEnumerator(*enumerator_ptr)) {
+ if (parseEnumerator(*enumerator_ptr))
enumerator_ptr = &(*enumerator_ptr)->next;
- }
if (LA() == T_COMMA && LA(2) == T_RBRACE)
ast->stray_comma_token = consumeToken();
@@ -2182,11 +2178,10 @@ bool Parser::parseQtPropertyDeclaration(DeclarationAST *&node)
SimpleNameAST *property_name = new (_pool) SimpleNameAST;
// special case: keywords are allowed for property names!
- if (tok().isKeyword()) {
+ if (tok().isKeyword())
property_name->identifier_token = consumeToken();
- } else {
+ else
match(T_IDENTIFIER, &property_name->identifier_token);
- }
ast->property_name = property_name;
QtPropertyDeclarationItemListAST **iter = &ast->property_declaration_item_list;
@@ -3484,11 +3479,10 @@ bool Parser::parseForStatement(StatementAST *&node)
ast->colon_token = consumeToken();
blockErrors(blocked);
- if (LA() == T_LBRACE) {
+ if (LA() == T_LBRACE)
parseBracedInitList0x(ast->expression);
- } else {
+ else
parseExpression(ast->expression);
- }
match(T_RPAREN, &ast->rparen_token);
parseStatement(ast->statement);
@@ -5093,11 +5087,10 @@ bool Parser::parseNewArrayDeclarator(NewArrayDeclaratorListAST *&node)
bool Parser::parseNewInitializer(ExpressionAST *&node)
{
DEBUG_THIS_RULE();
- if (LA() == T_LPAREN) {
+ if (LA() == T_LPAREN)
return parseExpressionListParen(node);
- } else if (_cxx0xEnabled && LA() == T_LBRACE) {
+ else if (_cxx0xEnabled && LA() == T_LBRACE)
return parseBracedInitList0x(node);
- }
return false;
}
@@ -5787,9 +5780,8 @@ bool Parser::parseObjCMethodDefinition(DeclarationAST *&node)
// - (void) foo; { body; }
// so a method is a forward declaration when it doesn't have a _body_.
// However, we still need to read the semicolon.
- if (LA() == T_SEMICOLON) {
+ if (LA() == T_SEMICOLON)
ast->semicolon_token = consumeToken();
- }
parseFunctionBody(ast->function_body);