Skip to content

Commit 06e9742

Browse files
committed
Clang-format modified lines in parse.cpp
Also added braces where an if condition spans multiple lines, and replace one case of if(...) return true; return false; by return (...);
1 parent 657b77a commit 06e9742

File tree

1 file changed

+63
-64
lines changed

1 file changed

+63
-64
lines changed

src/cpp/parse.cpp

Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,12 @@ bool Parser::rDefinition(cpp_itemt &item)
573573
return rNamespaceSpec(item.make_namespace_spec());
574574
else if(t==TOK_INLINE && lex.LookAhead(1)==TOK_NAMESPACE)
575575
return rNamespaceSpec(item.make_namespace_spec());
576-
else if(t==TOK_USING &&
577-
is_identifier(lex.LookAhead(1)) &&
578-
lex.LookAhead(2)=='=')
576+
else if(
577+
t == TOK_USING && is_identifier(lex.LookAhead(1)) &&
578+
lex.LookAhead(2) == '=')
579+
{
579580
return rTypedefUsing(item.make_declaration());
581+
}
580582
else if(t==TOK_USING)
581583
return rUsing(item.make_using());
582584
else if(t==TOK_STATIC_ASSERT)
@@ -756,27 +758,19 @@ bool Parser::isTypeSpecifier()
756758
{
757759
int t=lex.LookAhead(0);
758760

759-
if(is_identifier(t) || t==TOK_SCOPE
760-
|| t==TOK_CONSTEXPR || t==TOK_CONST || t==TOK_VOLATILE || t==TOK_RESTRICT
761-
|| t==TOK_CHAR || t==TOK_INT || t==TOK_SHORT || t==TOK_LONG
762-
|| t==TOK_CHAR16_T || t==TOK_CHAR32_T
763-
|| t==TOK_WCHAR_T || t==TOK_COMPLEX // new !!!
764-
|| t==TOK_SIGNED || t==TOK_UNSIGNED || t==TOK_FLOAT || t==TOK_DOUBLE
765-
|| t==TOK_INT8 || t==TOK_INT16 || t==TOK_INT32 || t==TOK_INT64
766-
|| t==TOK_GCC_INT128
767-
|| t==TOK_PTR32 || t==TOK_PTR64
768-
|| t==TOK_GCC_FLOAT80 || t==TOK_GCC_FLOAT128
769-
|| t==TOK_VOID || t==TOK_BOOL || t==TOK_CPROVER_BOOL
770-
|| t==TOK_CLASS || t==TOK_STRUCT || t==TOK_UNION || t==TOK_ENUM
771-
|| t==TOK_INTERFACE
772-
|| t==TOK_TYPENAME
773-
|| t==TOK_TYPEOF
774-
|| t==TOK_DECLTYPE
775-
|| t==TOK_UNDERLYING_TYPE
776-
)
777-
return true;
778-
779-
return false;
761+
return is_identifier(t) || t == TOK_SCOPE || t == TOK_CONSTEXPR ||
762+
t == TOK_CONST || t == TOK_VOLATILE || t == TOK_RESTRICT ||
763+
t == TOK_CHAR || t == TOK_INT || t == TOK_SHORT || t == TOK_LONG ||
764+
t == TOK_CHAR16_T || t == TOK_CHAR32_T || t == TOK_WCHAR_T ||
765+
t == TOK_COMPLEX // new !!!
766+
|| t == TOK_SIGNED || t == TOK_UNSIGNED || t == TOK_FLOAT ||
767+
t == TOK_DOUBLE || t == TOK_INT8 || t == TOK_INT16 || t == TOK_INT32 ||
768+
t == TOK_INT64 || t == TOK_GCC_INT128 || t == TOK_PTR32 ||
769+
t == TOK_PTR64 || t == TOK_GCC_FLOAT80 || t == TOK_GCC_FLOAT128 ||
770+
t == TOK_VOID || t == TOK_BOOL || t == TOK_CPROVER_BOOL ||
771+
t == TOK_CLASS || t == TOK_STRUCT || t == TOK_UNION || t == TOK_ENUM ||
772+
t == TOK_INTERFACE || t == TOK_TYPENAME || t == TOK_TYPEOF ||
773+
t == TOK_DECLTYPE || t == TOK_UNDERLYING_TYPE;
780774
}
781775

782776
/*
@@ -1247,8 +1241,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration)
12471241

12481242
cpp_tokent tk1, tk2;
12491243

1250-
if(lex.get_token(tk1)!=TOK_CLASS ||
1251-
!is_identifier(lex.get_token(tk2)))
1244+
if(lex.get_token(tk1) != TOK_CLASS || !is_identifier(lex.get_token(tk2)))
12521245
return false;
12531246

12541247
// Ptree cspec=new PtreeClassSpec(new LeafReserved(tk1),
@@ -1462,9 +1455,12 @@ bool Parser::rDeclaration(cpp_declarationt &declaration)
14621455
<< '\n';
14631456
#endif
14641457

1465-
if(cv_q.is_not_nil() &&
1466-
((is_identifier(t) && lex.LookAhead(1)=='=') || t=='*'))
1458+
if(
1459+
cv_q.is_not_nil() &&
1460+
((is_identifier(t) && lex.LookAhead(1) == '=') || t == '*'))
1461+
{
14671462
return rConstDeclaration(declaration);
1463+
}
14681464
else
14691465
return rOtherDeclaration(declaration, storage_spec, member_spec, cv_q);
14701466
}
@@ -3080,8 +3076,9 @@ bool Parser::rDeclarator(
30803076
d_inner.swap(declarator2.type());
30813077
name.swap(declarator2.name());
30823078
}
3083-
else if(kind!=kCastDeclarator &&
3084-
(kind==kDeclarator || is_identifier(t) || t==TOK_SCOPE))
3079+
else if(
3080+
kind != kCastDeclarator &&
3081+
(kind == kDeclarator || is_identifier(t) || t == TOK_SCOPE))
30853082
{
30863083
#ifdef DEBUG
30873084
std::cout << std::string(__indent, ' ') << "Parser::rDeclarator2 6\n";
@@ -3816,31 +3813,33 @@ bool Parser::rPtrToMember(irept &ptr_to_mem)
38163813
break;
38173814

38183815
case '<':
3819-
{
3820-
irept args;
3821-
if(!rTemplateArgs(args))
3822-
return false;
3816+
{
3817+
irept args;
3818+
if(!rTemplateArgs(args))
3819+
return false;
38233820

3824-
components.push_back(irept(ID_template_args));
3825-
components.back().add(ID_arguments).swap(args);
3821+
components.push_back(irept(ID_template_args));
3822+
components.back().add(ID_arguments).swap(args);
3823+
3824+
if(lex.LookAhead(0) != TOK_SCOPE)
3825+
return false;
38263826

3827-
if(lex.LookAhead(0)!=TOK_SCOPE)
3828-
return false;
3829-
}
38303827
break;
3828+
}
38313829

38323830
case TOK_GCC_IDENTIFIER:
38333831
case TOK_MSC_IDENTIFIER:
3832+
{
38343833
lex.get_token(tk);
38353834
components.push_back(cpp_namet::namet(tk.data.get(ID_C_base_name)));
38363835
set_location(components.back(), tk);
38373836

3838-
{
3839-
int t=lex.LookAhead(0);
3840-
if(t!=TOK_SCOPE && t!='<')
3841-
return false;
3842-
}
3837+
int t = lex.LookAhead(0);
3838+
if(t != TOK_SCOPE && t != '<')
3839+
return false;
3840+
38433841
break;
3842+
}
38443843

38453844
case TOK_SCOPE:
38463845
lex.get_token(tk);
@@ -4724,10 +4723,12 @@ bool Parser::rClassMember(cpp_itemt &member)
47244723
return rTypedef(member.make_declaration());
47254724
else if(t==TOK_TEMPLATE)
47264725
return rTemplateDecl(member.make_declaration());
4727-
else if(t==TOK_USING &&
4728-
is_identifier(lex.LookAhead(1)) &&
4729-
lex.LookAhead(2)=='=')
4726+
else if(
4727+
t == TOK_USING && is_identifier(lex.LookAhead(1)) &&
4728+
lex.LookAhead(2) == '=')
4729+
{
47304730
return rTypedefUsing(member.make_declaration());
4731+
}
47314732
else if(t==TOK_USING)
47324733
return rUsing(member.make_using());
47334734
else if(t==TOK_STATIC_ASSERT)
@@ -5581,31 +5582,29 @@ bool Parser::rTypeNameOrFunctionType(typet &tname)
55815582
// TODO -- cruel hack for Clang's type_traits:
55825583
// struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...),
55835584
// true, false>
5584-
if(is_identifier(lex.LookAhead(0)) &&
5585-
lex.LookAhead(1)==TOK_SCOPE &&
5586-
lex.LookAhead(2)=='*' &&
5587-
lex.LookAhead(3)==')' &&
5588-
lex.LookAhead(4)=='(')
5585+
if(
5586+
is_identifier(lex.LookAhead(0)) && lex.LookAhead(1) == TOK_SCOPE &&
5587+
lex.LookAhead(2) == '*' && lex.LookAhead(3) == ')' &&
5588+
lex.LookAhead(4) == '(')
55895589
{
55905590
lex.get_token();
55915591
lex.get_token();
55925592
lex.get_token();
55935593
lex.get_token();
55945594
lex.get_token();
55955595
}
5596-
else if(is_identifier(lex.LookAhead(0)) &&
5597-
lex.LookAhead(1)==')' &&
5598-
lex.LookAhead(2)=='(')
5596+
else if(
5597+
is_identifier(lex.LookAhead(0)) && lex.LookAhead(1) == ')' &&
5598+
lex.LookAhead(2) == '(')
55995599
{
56005600
lex.get_token(op);
56015601
type.set(ID_identifier, op.data.get(ID_C_base_name));
56025602
lex.get_token();
56035603
lex.get_token();
56045604
}
5605-
else if(lex.LookAhead(0)=='*' &&
5606-
is_identifier(lex.LookAhead(1)) &&
5607-
lex.LookAhead(2)==')' &&
5608-
lex.LookAhead(3)=='(')
5605+
else if(
5606+
lex.LookAhead(0) == '*' && is_identifier(lex.LookAhead(1)) &&
5607+
lex.LookAhead(2) == ')' && lex.LookAhead(3) == '(')
56095608
{
56105609
lex.get_token(op);
56115610
lex.get_token(op);
@@ -7073,7 +7072,7 @@ bool Parser::moreVarName()
70737072
if(lex.LookAhead(0)==TOK_SCOPE)
70747073
{
70757074
int t=lex.LookAhead(1);
7076-
if(is_identifier(t) || t=='~' || t==TOK_OPERATOR || t==TOK_TEMPLATE)
7075+
if(is_identifier(t) || t == '~' || t == TOK_OPERATOR || t == TOK_TEMPLATE)
70777076
return true;
70787077
}
70797078

@@ -7504,8 +7503,7 @@ optionalt<codet> Parser::rStatement()
75047503

75057504
case TOK_USING:
75067505
{
7507-
if(is_identifier(lex.LookAhead(1)) &&
7508-
lex.LookAhead(2)=='=')
7506+
if(is_identifier(lex.LookAhead(1)) && lex.LookAhead(2) == '=')
75097507
{
75107508
cpp_declarationt declaration;
75117509
if(!rTypedefUsing(declaration))
@@ -8235,8 +8233,9 @@ optionalt<codet> Parser::rDeclarationStatement()
82358233
<< "Parser::rDeclarationStatement 3 " << t << '\n';
82368234
#endif
82378235

8238-
if(cv_q.is_not_nil() &&
8239-
((is_identifier(t) && lex.LookAhead(1)=='=') || t=='*'))
8236+
if(
8237+
cv_q.is_not_nil() &&
8238+
((is_identifier(t) && lex.LookAhead(1) == '=') || t == '*'))
82408239
{
82418240
#ifdef DEBUG
82428241
std::cout << std::string(__indent, ' ')

0 commit comments

Comments
 (0)