@@ -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
}
@@ -3082,8 +3078,9 @@ bool Parser::rDeclarator(
3082
3078
d_inner.swap (declarator2.type ());
3083
3079
name.swap (declarator2.name ());
3084
3080
}
3085
- else if (kind!=kCastDeclarator &&
3086
- (kind==kDeclarator || is_identifier (t) || t==TOK_SCOPE))
3081
+ else if (
3082
+ kind != kCastDeclarator &&
3083
+ (kind == kDeclarator || is_identifier (t) || t == TOK_SCOPE))
3087
3084
{
3088
3085
#ifdef DEBUG
3089
3086
std::cout << std::string (__indent, ' ' ) << " Parser::rDeclarator2 6\n " ;
@@ -3818,31 +3815,33 @@ bool Parser::rPtrToMember(irept &ptr_to_mem)
3818
3815
break ;
3819
3816
3820
3817
case ' <' :
3821
- {
3822
- irept args;
3823
- if (!rTemplateArgs (args))
3824
- return false ;
3818
+ {
3819
+ irept args;
3820
+ if (!rTemplateArgs (args))
3821
+ return false ;
3825
3822
3826
- components.push_back (irept (ID_template_args));
3827
- components.back ().add (ID_arguments).swap (args);
3823
+ components.push_back (irept (ID_template_args));
3824
+ components.back ().add (ID_arguments).swap (args);
3825
+
3826
+ if (lex.LookAhead (0 ) != TOK_SCOPE)
3827
+ return false ;
3828
3828
3829
- if (lex.LookAhead (0 )!=TOK_SCOPE)
3830
- return false ;
3831
- }
3832
3829
break ;
3830
+ }
3833
3831
3834
3832
case TOK_GCC_IDENTIFIER:
3835
3833
case TOK_MSC_IDENTIFIER:
3834
+ {
3836
3835
lex.get_token (tk);
3837
3836
components.push_back (cpp_namet::namet (tk.data .get (ID_C_base_name)));
3838
3837
set_location (components.back (), tk);
3839
3838
3840
- {
3841
- int t=lex.LookAhead (0 );
3842
- if (t!=TOK_SCOPE && t!=' <' )
3843
- return false ;
3844
- }
3839
+ int t = lex.LookAhead (0 );
3840
+ if (t != TOK_SCOPE && t != ' <' )
3841
+ return false ;
3842
+
3845
3843
break ;
3844
+ }
3846
3845
3847
3846
case TOK_SCOPE:
3848
3847
lex.get_token (tk);
@@ -4726,10 +4725,12 @@ bool Parser::rClassMember(cpp_itemt &member)
4726
4725
return rTypedef (member.make_declaration ());
4727
4726
else if (t==TOK_TEMPLATE)
4728
4727
return rTemplateDecl (member.make_declaration ());
4729
- else if (t==TOK_USING &&
4730
- is_identifier (lex.LookAhead (1 )) &&
4731
- lex.LookAhead (2 )==' =' )
4728
+ else if (
4729
+ t == TOK_USING && is_identifier (lex.LookAhead (1 )) &&
4730
+ lex.LookAhead (2 ) == ' =' )
4731
+ {
4732
4732
return rTypedefUsing (member.make_declaration ());
4733
+ }
4733
4734
else if (t==TOK_USING)
4734
4735
return rUsing (member.make_using ());
4735
4736
else if (t==TOK_STATIC_ASSERT)
@@ -5583,31 +5584,29 @@ bool Parser::rTypeNameOrFunctionType(typet &tname)
5583
5584
// TODO -- cruel hack for Clang's type_traits:
5584
5585
// struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...),
5585
5586
// true, false>
5586
- if (is_identifier (lex.LookAhead (0 )) &&
5587
- lex.LookAhead (1 )==TOK_SCOPE &&
5588
- lex.LookAhead (2 )==' *' &&
5589
- lex.LookAhead (3 )==' )' &&
5590
- lex.LookAhead (4 )==' (' )
5587
+ if (
5588
+ is_identifier (lex.LookAhead (0 )) && lex.LookAhead (1 ) == TOK_SCOPE &&
5589
+ lex.LookAhead (2 ) == ' *' && lex.LookAhead (3 ) == ' )' &&
5590
+ lex.LookAhead (4 ) == ' (' )
5591
5591
{
5592
5592
lex.get_token ();
5593
5593
lex.get_token ();
5594
5594
lex.get_token ();
5595
5595
lex.get_token ();
5596
5596
lex.get_token ();
5597
5597
}
5598
- else if (is_identifier (lex. LookAhead ( 0 )) &&
5599
- lex.LookAhead (1 )== ' )' &&
5600
- lex.LookAhead (2 )== ' (' )
5598
+ else if (
5599
+ is_identifier (lex. LookAhead ( 0 )) && lex.LookAhead (1 ) == ' )' &&
5600
+ lex.LookAhead (2 ) == ' (' )
5601
5601
{
5602
5602
lex.get_token (op);
5603
5603
type.set (ID_identifier, op.data .get (ID_C_base_name));
5604
5604
lex.get_token ();
5605
5605
lex.get_token ();
5606
5606
}
5607
- else if (lex.LookAhead (0 )==' *' &&
5608
- is_identifier (lex.LookAhead (1 )) &&
5609
- lex.LookAhead (2 )==' )' &&
5610
- lex.LookAhead (3 )==' (' )
5607
+ else if (
5608
+ lex.LookAhead (0 ) == ' *' && is_identifier (lex.LookAhead (1 )) &&
5609
+ lex.LookAhead (2 ) == ' )' && lex.LookAhead (3 ) == ' (' )
5611
5610
{
5612
5611
lex.get_token (op);
5613
5612
lex.get_token (op);
@@ -7075,7 +7074,7 @@ bool Parser::moreVarName()
7075
7074
if (lex.LookAhead (0 )==TOK_SCOPE)
7076
7075
{
7077
7076
int t=lex.LookAhead (1 );
7078
- if (is_identifier (t) || t== ' ~' || t== TOK_OPERATOR || t== TOK_TEMPLATE)
7077
+ if (is_identifier (t) || t == ' ~' || t == TOK_OPERATOR || t == TOK_TEMPLATE)
7079
7078
return true ;
7080
7079
}
7081
7080
@@ -7506,8 +7505,7 @@ optionalt<codet> Parser::rStatement()
7506
7505
7507
7506
case TOK_USING:
7508
7507
{
7509
- if (is_identifier (lex.LookAhead (1 )) &&
7510
- lex.LookAhead (2 )==' =' )
7508
+ if (is_identifier (lex.LookAhead (1 )) && lex.LookAhead (2 ) == ' =' )
7511
7509
{
7512
7510
cpp_declarationt declaration;
7513
7511
if (!rTypedefUsing (declaration))
@@ -8238,8 +8236,9 @@ optionalt<codet> Parser::rDeclarationStatement()
8238
8236
<< " Parser::rDeclarationStatement 3 " << t << ' \n ' ;
8239
8237
#endif
8240
8238
8241
- if (cv_q.is_not_nil () &&
8242
- ((is_identifier (t) && lex.LookAhead (1 )==' =' ) || t==' *' ))
8239
+ if (
8240
+ cv_q.is_not_nil () &&
8241
+ ((is_identifier (t) && lex.LookAhead (1 ) == ' =' ) || t == ' *' ))
8243
8242
{
8244
8243
#ifdef DEBUG
8245
8244
std::cout << std::string (__indent, ' ' )
0 commit comments