@@ -573,10 +573,12 @@ bool Parser::rDefinition(cpp_itemt &item)
573
573
return rNamespaceSpec (item.make_namespace_spec ());
574
574
else if (t==TOK_INLINE && lex.LookAhead (1 )==TOK_NAMESPACE)
575
575
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
+ {
579
580
return rTypedefUsing (item.make_declaration ());
581
+ }
580
582
else if (t==TOK_USING)
581
583
return rUsing (item.make_using ());
582
584
else if (t==TOK_STATIC_ASSERT)
@@ -756,27 +758,19 @@ bool Parser::isTypeSpecifier()
756
758
{
757
759
int t=lex.LookAhead (0 );
758
760
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;
780
774
}
781
775
782
776
/*
@@ -1247,8 +1241,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration)
1247
1241
1248
1242
cpp_tokent tk1, tk2;
1249
1243
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)))
1252
1245
return false ;
1253
1246
1254
1247
// Ptree cspec=new PtreeClassSpec(new LeafReserved(tk1),
@@ -1462,9 +1455,12 @@ bool Parser::rDeclaration(cpp_declarationt &declaration)
1462
1455
<< ' \n ' ;
1463
1456
#endif
1464
1457
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
+ {
1467
1462
return rConstDeclaration (declaration);
1463
+ }
1468
1464
else
1469
1465
return rOtherDeclaration (declaration, storage_spec, member_spec, cv_q);
1470
1466
}
@@ -3080,8 +3076,9 @@ bool Parser::rDeclarator(
3080
3076
d_inner.swap (declarator2.type ());
3081
3077
name.swap (declarator2.name ());
3082
3078
}
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))
3085
3082
{
3086
3083
#ifdef DEBUG
3087
3084
std::cout << std::string (__indent, ' ' ) << " Parser::rDeclarator2 6\n " ;
@@ -3816,31 +3813,33 @@ bool Parser::rPtrToMember(irept &ptr_to_mem)
3816
3813
break ;
3817
3814
3818
3815
case ' <' :
3819
- {
3820
- irept args;
3821
- if (!rTemplateArgs (args))
3822
- return false ;
3816
+ {
3817
+ irept args;
3818
+ if (!rTemplateArgs (args))
3819
+ return false ;
3823
3820
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 ;
3826
3826
3827
- if (lex.LookAhead (0 )!=TOK_SCOPE)
3828
- return false ;
3829
- }
3830
3827
break ;
3828
+ }
3831
3829
3832
3830
case TOK_GCC_IDENTIFIER:
3833
3831
case TOK_MSC_IDENTIFIER:
3832
+ {
3834
3833
lex.get_token (tk);
3835
3834
components.push_back (cpp_namet::namet (tk.data .get (ID_C_base_name)));
3836
3835
set_location (components.back (), tk);
3837
3836
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
+
3843
3841
break ;
3842
+ }
3844
3843
3845
3844
case TOK_SCOPE:
3846
3845
lex.get_token (tk);
@@ -4724,10 +4723,12 @@ bool Parser::rClassMember(cpp_itemt &member)
4724
4723
return rTypedef (member.make_declaration ());
4725
4724
else if (t==TOK_TEMPLATE)
4726
4725
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
+ {
4730
4730
return rTypedefUsing (member.make_declaration ());
4731
+ }
4731
4732
else if (t==TOK_USING)
4732
4733
return rUsing (member.make_using ());
4733
4734
else if (t==TOK_STATIC_ASSERT)
@@ -5581,31 +5582,29 @@ bool Parser::rTypeNameOrFunctionType(typet &tname)
5581
5582
// TODO -- cruel hack for Clang's type_traits:
5582
5583
// struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...),
5583
5584
// 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 ) == ' (' )
5589
5589
{
5590
5590
lex.get_token ();
5591
5591
lex.get_token ();
5592
5592
lex.get_token ();
5593
5593
lex.get_token ();
5594
5594
lex.get_token ();
5595
5595
}
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 ) == ' (' )
5599
5599
{
5600
5600
lex.get_token (op);
5601
5601
type.set (ID_identifier, op.data .get (ID_C_base_name));
5602
5602
lex.get_token ();
5603
5603
lex.get_token ();
5604
5604
}
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 ) == ' (' )
5609
5608
{
5610
5609
lex.get_token (op);
5611
5610
lex.get_token (op);
@@ -7073,7 +7072,7 @@ bool Parser::moreVarName()
7073
7072
if (lex.LookAhead (0 )==TOK_SCOPE)
7074
7073
{
7075
7074
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)
7077
7076
return true ;
7078
7077
}
7079
7078
@@ -7504,8 +7503,7 @@ optionalt<codet> Parser::rStatement()
7504
7503
7505
7504
case TOK_USING:
7506
7505
{
7507
- if (is_identifier (lex.LookAhead (1 )) &&
7508
- lex.LookAhead (2 )==' =' )
7506
+ if (is_identifier (lex.LookAhead (1 )) && lex.LookAhead (2 ) == ' =' )
7509
7507
{
7510
7508
cpp_declarationt declaration;
7511
7509
if (!rTypedefUsing (declaration))
@@ -8235,8 +8233,9 @@ optionalt<codet> Parser::rDeclarationStatement()
8235
8233
<< " Parser::rDeclarationStatement 3 " << t << ' \n ' ;
8236
8234
#endif
8237
8235
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 == ' *' ))
8240
8239
{
8241
8240
#ifdef DEBUG
8242
8241
std::cout << std::string (__indent, ' ' )
0 commit comments