Skip to content

Commit 75f7615

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 cc7f915 commit 75f7615

File tree

1 file changed

+67
-70
lines changed

1 file changed

+67
-70
lines changed

src/cpp/parse.cpp

Lines changed: 67 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,12 @@ bool Parser::rDefinition(cpp_itemt &item)
576576
return rNamespaceSpec(item.make_namespace_spec());
577577
else if(t==TOK_INLINE && lex.LookAhead(1)==TOK_NAMESPACE)
578578
return rNamespaceSpec(item.make_namespace_spec());
579-
else if(t==TOK_USING &&
580-
is_identifier(lex.LookAhead(1)) &&
581-
lex.LookAhead(2)=='=')
579+
else if(
580+
t == TOK_USING && is_identifier(lex.LookAhead(1)) &&
581+
lex.LookAhead(2) == '=')
582+
{
582583
return rTypedefUsing(item.make_declaration());
584+
}
583585
else if(t==TOK_USING)
584586
return rUsing(item.make_using());
585587
else if(t==TOK_STATIC_ASSERT)
@@ -759,27 +761,19 @@ bool Parser::isTypeSpecifier()
759761
{
760762
int t=lex.LookAhead(0);
761763

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

785779
/*
@@ -1250,8 +1244,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration)
12501244

12511245
cpp_tokent tk1, tk2;
12521246

1253-
if(lex.get_token(tk1)!=TOK_CLASS ||
1254-
!is_identifier(lex.get_token(tk2)))
1247+
if(lex.get_token(tk1) != TOK_CLASS || !is_identifier(lex.get_token(tk2)))
12551248
return false;
12561249

12571250
// Ptree cspec=new PtreeClassSpec(new LeafReserved(tk1),
@@ -1465,9 +1458,12 @@ bool Parser::rDeclaration(cpp_declarationt &declaration)
14651458
<< '\n';
14661459
#endif
14671460

1468-
if(cv_q.is_not_nil() &&
1469-
((is_identifier(t) && lex.LookAhead(1)=='=') || t=='*'))
1461+
if(
1462+
cv_q.is_not_nil() &&
1463+
((is_identifier(t) && lex.LookAhead(1) == '=') || t == '*'))
1464+
{
14701465
return rConstDeclaration(declaration);
1466+
}
14711467
else
14721468
return rOtherDeclaration(declaration, storage_spec, member_spec, cv_q);
14731469
}
@@ -3083,8 +3079,9 @@ bool Parser::rDeclarator(
30833079
d_inner.swap(declarator2.type());
30843080
name.swap(declarator2.name());
30853081
}
3086-
else if(kind!=kCastDeclarator &&
3087-
(kind==kDeclarator || is_identifier(t) || t==TOK_SCOPE))
3082+
else if(
3083+
kind != kCastDeclarator &&
3084+
(kind == kDeclarator || is_identifier(t) || t == TOK_SCOPE))
30883085
{
30893086
#ifdef DEBUG
30903087
std::cout << std::string(__indent, ' ') << "Parser::rDeclarator2 6\n";
@@ -3832,29 +3829,29 @@ bool Parser::rPtrToMember(irept &ptr_to_mem)
38323829
}
38333830
break;
38343831

3835-
case TOK_GCC_IDENTIFIER:
3836-
case TOK_MSC_IDENTIFIER:
3837-
lex.get_token(tk);
3838-
components.push_back(cpp_namet::namet(tk.data.get(ID_C_base_name)));
3839-
set_location(components.back(), tk);
3840-
3841-
{
3842-
int t=lex.LookAhead(0);
3843-
if(t!=TOK_SCOPE && t!='<')
3844-
return false;
3845-
}
3846-
break;
3832+
case TOK_GCC_IDENTIFIER:
3833+
case TOK_MSC_IDENTIFIER:
3834+
lex.get_token(tk);
3835+
components.push_back(cpp_namet::namet(tk.data.get(ID_C_base_name)));
3836+
set_location(components.back(), tk);
38473837

3848-
case TOK_SCOPE:
3849-
lex.get_token(tk);
3850-
components.push_back(irept("::"));
3851-
set_location(components.back(), tk);
3838+
{
3839+
int t = lex.LookAhead(0);
3840+
if(t != TOK_SCOPE && t != '<')
3841+
return false;
3842+
}
3843+
break;
38523844

3853-
// done if next token is '*'
3854-
if(lex.LookAhead(0) == '*')
3855-
{
3845+
case TOK_SCOPE:
38563846
lex.get_token(tk);
3857-
ptr_to_mem.swap(ptm);
3847+
components.push_back(irept("::"));
3848+
set_location(components.back(), tk);
3849+
3850+
// done if next token is '*'
3851+
if(lex.LookAhead(0) == '*')
3852+
{
3853+
lex.get_token(tk);
3854+
ptr_to_mem.swap(ptm);
38583855

38593856
#ifdef DEBUG
38603857
std::cout << std::string(__indent, ' ') << "Parser::rPtrToMember 1\n";
@@ -4727,10 +4724,12 @@ bool Parser::rClassMember(cpp_itemt &member)
47274724
return rTypedef(member.make_declaration());
47284725
else if(t==TOK_TEMPLATE)
47294726
return rTemplateDecl(member.make_declaration());
4730-
else if(t==TOK_USING &&
4731-
is_identifier(lex.LookAhead(1)) &&
4732-
lex.LookAhead(2)=='=')
4727+
else if(
4728+
t == TOK_USING && is_identifier(lex.LookAhead(1)) &&
4729+
lex.LookAhead(2) == '=')
4730+
{
47334731
return rTypedefUsing(member.make_declaration());
4732+
}
47344733
else if(t==TOK_USING)
47354734
return rUsing(member.make_using());
47364735
else if(t==TOK_STATIC_ASSERT)
@@ -5584,31 +5583,29 @@ bool Parser::rTypeNameOrFunctionType(typet &tname)
55845583
// TODO -- cruel hack for Clang's type_traits:
55855584
// struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...),
55865585
// true, false>
5587-
if(is_identifier(lex.LookAhead(0)) &&
5588-
lex.LookAhead(1)==TOK_SCOPE &&
5589-
lex.LookAhead(2)=='*' &&
5590-
lex.LookAhead(3)==')' &&
5591-
lex.LookAhead(4)=='(')
5586+
if(
5587+
is_identifier(lex.LookAhead(0)) && lex.LookAhead(1) == TOK_SCOPE &&
5588+
lex.LookAhead(2) == '*' && lex.LookAhead(3) == ')' &&
5589+
lex.LookAhead(4) == '(')
55925590
{
55935591
lex.get_token();
55945592
lex.get_token();
55955593
lex.get_token();
55965594
lex.get_token();
55975595
lex.get_token();
55985596
}
5599-
else if(is_identifier(lex.LookAhead(0)) &&
5600-
lex.LookAhead(1)==')' &&
5601-
lex.LookAhead(2)=='(')
5597+
else if(
5598+
is_identifier(lex.LookAhead(0)) && lex.LookAhead(1) == ')' &&
5599+
lex.LookAhead(2) == '(')
56025600
{
56035601
lex.get_token(op);
56045602
type.set(ID_identifier, op.data.get(ID_C_base_name));
56055603
lex.get_token();
56065604
lex.get_token();
56075605
}
5608-
else if(lex.LookAhead(0)=='*' &&
5609-
is_identifier(lex.LookAhead(1)) &&
5610-
lex.LookAhead(2)==')' &&
5611-
lex.LookAhead(3)=='(')
5606+
else if(
5607+
lex.LookAhead(0) == '*' && is_identifier(lex.LookAhead(1)) &&
5608+
lex.LookAhead(2) == ')' && lex.LookAhead(3) == '(')
56125609
{
56135610
lex.get_token(op);
56145611
lex.get_token(op);
@@ -7076,7 +7073,7 @@ bool Parser::moreVarName()
70767073
if(lex.LookAhead(0)==TOK_SCOPE)
70777074
{
70787075
int t=lex.LookAhead(1);
7079-
if(is_identifier(t) || t=='~' || t==TOK_OPERATOR || t==TOK_TEMPLATE)
7076+
if(is_identifier(t) || t == '~' || t == TOK_OPERATOR || t == TOK_TEMPLATE)
70807077
return true;
70817078
}
70827079

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

75087505
case TOK_USING:
75097506
{
7510-
if(is_identifier(lex.LookAhead(1)) &&
7511-
lex.LookAhead(2)=='=')
7507+
if(is_identifier(lex.LookAhead(1)) && lex.LookAhead(2) == '=')
75127508
{
75137509
cpp_declarationt declaration;
75147510
if(!rTypedefUsing(declaration))
@@ -8238,8 +8234,9 @@ optionalt<codet> Parser::rDeclarationStatement()
82388234
<< "Parser::rDeclarationStatement 3 " << t << '\n';
82398235
#endif
82408236

8241-
if(cv_q.is_not_nil() &&
8242-
((is_identifier(t) && lex.LookAhead(1)=='=') || t=='*'))
8237+
if(
8238+
cv_q.is_not_nil() &&
8239+
((is_identifier(t) && lex.LookAhead(1) == '=') || t == '*'))
82438240
{
82448241
#ifdef DEBUG
82458242
std::cout << std::string(__indent, ' ')

0 commit comments

Comments
 (0)